Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config loggers by labels #50

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SimonRichardson
Copy link
Member

@SimonRichardson SimonRichardson commented May 6, 2024

To support labels from Juju, we would like to be able to
configure loggers by their labels. So if a logger has a label of a
model namespace (UUID) then searching from the root module to set the
level of a module should be possible.

Label matching can be applied to the loggers by providing a set of labels
to the ConfigureLoggers method. If a logger has a label that matches the
provided labels, then the logger will be configured with the provided level.
If the logger does not have a label that matches the provided labels, then
the logger will not be configured. No labels will configure all loggers in the
specification.


In addition, I've removed the attachment of the dynamic labels to the logger
type. There isn't a usage from Juju's perspective to ever need them. Loggo
is a hierarchical model, where loggers inherit from their parents. The original
label concept didn't follow that concept. For example, module names walk
their parents for an effective level if a level hasn't been set. We do the inverse
for labels, where the parent sets the child labels on construction (labels are
immutable atm), but they do follow the same concept; child-parent relationship.

In order to support labels from Juju, we would like to be able to
configure loggers by their labels. So if a logger has a label of a
model namespace (UUID) then searching from the root module to set the
level of a module should be possible.

As you can configure both module names and labels at the same time,
this becomes tricky. We don't want users to be able to configure a
logger via a label directly and the label should always take
precedence over a user input.
Labels should not be applied to loggers. There is no way to reference
them directly from a root module. Labels for this concept should be
more like Attributes, something that can be dynamic for a given
logger, although I suspect that they should just be sent via the
Logf method.
It's much cleaner if we can reuse existing methods to provide the
additional functionality. The labels provide addition matching
capabilities to config loggers and will only config the loggers
that have a label intersection.
Take into consideration the labels when resetting the logger levels.
We don't want to reset all the logger levels if we're using a singular
global logger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant