Skip to content

Commit

Permalink
added global log level setter
Browse files Browse the repository at this point in the history
  • Loading branch information
visualDust committed Oct 8, 2024
1 parent 1628dd2 commit e2c8c49
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion neetbox/logging/_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,25 @@ def log_level(self, level: Union[LogLevel, str]):
"ERROR": LogLevel.ERROR,
}[level]
if type(level) is int:
assert level >= 0 and level <= 3
assert level >= 0 and level <= 3, "log level must be in [0, 3]"
level = LogLevel(level)
self._log_level = level

@classmethod
def set_global_log_level(cls, level: Union[LogLevel, str]):
if type(level) is str:
level = {
"ALL": LogLevel.ALL,
"DEBUG": LogLevel.DEBUG,
"INFO": LogLevel.INFO,
"WARNING": LogLevel.WARNING,
"ERROR": LogLevel.ERROR,
}[level]
if type(level) is int:
assert level >= 0 and level <= 3, "log level must be in [0, 3]"
level = LogLevel(level)
for logger in cls._IDENTITY2LOGGER.values():
logger.log_level = level

def writer(self, name: str):
def _add_private_writer(name, writer_func: Callable):
Expand Down

0 comments on commit e2c8c49

Please sign in to comment.