Skip to content
Merged
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
8 changes: 5 additions & 3 deletions src/palace/manager/util/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def logger_for_cls(cls: type[object]) -> logging.Logger:


class LoggerMixin:
"""Mixin that adds a logger with a standardized name"""
"""Mixin that adds a logger with a standardized name."""

@classmethod
@functools.cache
Expand All @@ -117,14 +117,16 @@ def logger(cls) -> logging.Logger:

This is cached so that we don't create a new logger every time
it is called.

Prefer ``self.log`` when calling from an instance method.
Use ``cls.logger()`` only in classmethods or static contexts.
"""
return logger_for_cls(cls)

@property
def log(self) -> LoggerType:
"""
A convenience property that returns the logger for the class,
so it is easier to access the logger from an instance.
The preferred way to access the logger from instance methods.
"""
return self.logger()

Expand Down
Loading