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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/abstract_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@
import upgrade
import workload

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")


class MySQLRouterCharm(ops.CharmBase, abc.ABC):
"""MySQL Router charm"""

def __init__(self, *args) -> None:
super().__init__(*args)
# `ops` adds juju debug-log handler to root logger and sets the root logger level to DEBUG
# The root logger will receive log messages from our Python dependencies (e.g. lightkube)
# which clutters juju debug-log.
# 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.


# Instantiate before registering other event observers
self._unit_lifecycle = lifecycle.Unit(
self, subordinated_relation_endpoint_names=self._subordinate_relation_endpoint_names
Expand Down
2 changes: 1 addition & 1 deletion src/kubernetes_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import rock
import upgrade

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")


class KubernetesRouterCharm(abstract_charm.MySQLRouterCharm):
Expand Down
2 changes: 1 addition & 1 deletion src/kubernetes_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import upgrade

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")


class DeployedWithoutTrust(Exception):
Expand Down
2 changes: 1 addition & 1 deletion src/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import ops

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")


class _UnitTearingDownAndAppActive(enum.IntEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/mysql_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import container

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")

_PASSWORD_LENGTH = 24

Expand Down
2 changes: 1 addition & 1 deletion src/relations/database_provides.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if typing.TYPE_CHECKING:
import abstract_charm

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")


class _RelationBreaking(Exception):
Expand Down
2 changes: 1 addition & 1 deletion src/relations/database_requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if typing.TYPE_CHECKING:
import abstract_charm

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")


class _MissingRelation(status_exception.StatusException):
Expand Down
2 changes: 1 addition & 1 deletion src/relations/remote_databag.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import status_exception

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")


class IncompleteDatabag(status_exception.StatusException):
Expand Down
2 changes: 1 addition & 1 deletion src/relations/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
if typing.TYPE_CHECKING:
import kubernetes_charm

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")

_PEER_RELATION_ENDPOINT_NAME = "mysql-router-peers"

Expand Down
2 changes: 1 addition & 1 deletion src/rock.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import container

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")

CONTAINER_NAME = "mysql-router"
_UNIX_USERNAME = "mysql"
Expand Down
2 changes: 1 addition & 1 deletion src/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import ops
import poetry.core.constraints.version as poetry_version

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")

PEER_RELATION_ENDPOINT_NAME = "upgrade-version-a"
RESUME_ACTION_NAME = "resume-upgrade"
Expand Down
2 changes: 1 addition & 1 deletion src/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import abstract_charm
import relations.database_requires

logger = logging.getLogger(__name__)
logger = logging.getLogger(f"router_charm.{__name__}")


class Workload:
Expand Down