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

Increase log level of root logger #145

Closed
wants to merge 1 commit into from
Closed

Conversation

carlcsaposs-canonical
Copy link
Contributor

ops adds juju debug-log handler to root logger—meaning all Python dependencies log to juju debug-log

lightkube's DEBUG and INFO level logs are particularly noisy and clutter up the debug log

Set root level logger to WARNING and only send DEBUG and INFO level logs to juju debug-log if the log is in the charm code

`ops` adds juju debug-log handler to root logger—meaning all Python dependencies log to juju debug-log

lightkube's DEBUG and INFO level logs are particularlly noisy and clutter up the debug log

Set root level logger to WARNING and only send DEBUG and INFO level logs to juju debug-log if the log is in the charm code
# Set root logger level
logging.getLogger().setLevel(logging.WARNING)
# Set charm logger level
logging.getLogger("router_charm").setLevel(logging.DEBUG)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this are you setting the router log level to ignore the model log level and always be on DEBUG?

If the idea is to quiet down lightkube related logs, there's another approach here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the model level filters the debug log

ops already always sends all DEBUG level logs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to let the router logs be default, and only set the log level for the lightkube logs as paulo suggested? if so, i definitely prefer that approach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's possible

do we want our all python deps to have debug level logs? to me it seems like we should raise the log level for all our python deps, instead of individually adding noisy deps

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: do we want our all python deps to have debug level logs
IMHO, no (by default).

Still, sometimes we need debug libraries (e.g. lightkube), can we use:
juju model-config -m foo logging-config="unit.mysql.lightkube/0=DEBUG"
to change verbosity for the specific library (from here)?

P.S. most-probably we should work with Juju team to provide such a capability for charm dependencies troubleshooting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't use model-config to change the verbosity for the library, but we can change the Python code

given that you believe the default should be to not debug packages (i.e. default is not to collect debug logs for packages) then it seems okay to change the code to enable debugging for packages

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fields never run charms with debug level (c) @phvalguima + charms should produce minimal amount of noise by default => default should be to not debug packages.

When user/developer need to debug complex application, he should be able to enable ALL debug messages and FILTER out necessary only (charm.py, dependency lib, maybe networking only in charm.py in the future). We are interested in a great debug experience... :-D

I have a strange feeling that we are not on the same page, happy to discuss this on sync! And tnx for taking care here!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is infinite storage available for debug messages? in this particular case, lightkube's debug messages are taking a significant amount of space

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we agree on keep these noisy packages with a Warning log level?
It should de-clutter it without preventing important messages to pop.

carlcsaposs-canonical added a commit that referenced this pull request Dec 12, 2023
`httpx` and `httpcore` (used by `lightkube`) have noisy INFO & DEBUG
level logs

Supersedes #145. It still seems a bit backwards to me to enable DEBUG
level logs for all python dependencies and then manually disable logging
for dependencies of our dependencies. Personally, I only think DEBUG
level logs are useful for charm ecosystem code (e.g. ops, the charm,
charm libs)—but it seems like the consensus [from this
discussion](#145 (comment))
is different
@paulomach
Copy link
Collaborator

Close this one then?

@carlcsaposs-canonical
Copy link
Contributor Author

Superseded by #176

github-actions bot added a commit to carlcsaposs-canonical/mysql-router-k8s-operator that referenced this pull request Jul 8, 2024
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.

4 participants