Skip to content

What's the point of providing one's own leveled backend if default one is used? #150

@gunnsth

Description

@gunnsth

Not sure if this is by design or not. But it's a bit odd.

return defaultBackend.IsEnabledFor(level, l.Module)

In my code I was establishing my own logger with its own backend, e.g.

	diagLogger, err := logging.GetLogger(diagModuleName)
	if err != nil {
		return ret, err
	}
	fileBackend := logging.NewLogBackend(diagnosticsFile, "", stdlog.LstdFlags)
	leveledBackend := logging.AddModuleLevel(fileBackend)
	leveledBackend.SetLevel(logging.DEBUG, diagModuleName)
	diagLogger.SetBackend(leveledBackend)

the effect of that leveledBackend.SetLevel(logging.DEBUG, diagModuleName) doesn't seem to do anything,
cause when we log with diagLogger.Debug then it seems to be querying the "default backend"...

I am solving this by just setting the log level for the given module in the default backend as well... But seemed worth pointing this out. Perhaps it's intended, but seemed a bit iffy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions