Skip to content

Commit

Permalink
Merge pull request #23 from cybercongress/logging
Browse files Browse the repository at this point in the history
Add argument of logger level
  • Loading branch information
cyborgshead authored Mar 28, 2024
2 parents f2a3885 + b7e5d81 commit ddf1535
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions cybertensor/ctlogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def on(cls):
def __new__(
cls,
config: Optional["Config"] = None,
level: Optional[int] = 40,
level: Optional[int] = None,
debug: Optional[bool] = None,
trace: Optional[bool] = None,
record_log: Optional[bool] = None,
Expand All @@ -111,7 +111,7 @@ def __new__(
config (Config, optional):
cybertensor.logging.config()
level (int, optional):
logger level (default: 40).
logger level in numeric value.
debug (bool, optional):
Turn on debug.
trace (bool, optional):
Expand All @@ -129,6 +129,9 @@ def __new__(
config = copy.deepcopy(config)
config.logging.debug = debug if debug is not None else config.logging.debug
config.logging.trace = trace if trace is not None else config.logging.trace
config.logging.level = (
level if level is not None else config.logging.level if config.logging.level is not None else 20
)
config.logging.record_log = (
record_log if record_log is not None else config.logging.record_log
)
Expand All @@ -151,7 +154,7 @@ def __new__(
# Add filtered sys.stdout.
cls.__std_sink__ = logger.add(
sys.stdout,
level=level,
level=config.logging.level,
filter=cls.log_filter,
colorize=True,
enqueue=True,
Expand Down Expand Up @@ -210,15 +213,21 @@ def add_args(cls, parser: argparse.ArgumentParser, prefix: str = None):
parser.add_argument(
"--" + prefix_str + "logging.debug",
action="store_true",
help="""Turn on cybertensor debugging information""",
help="""Turn on cybertensor debugging information.""",
default=default_logging_debug,
)
parser.add_argument(
"--" + prefix_str + "logging.trace",
action="store_true",
help="""Turn on cybertensor trace level information""",
help="""Turn on cybertensor trace level information.""",
default=default_logging_trace,
)
parser.add_argument(
"--" + prefix_str + "logging.level",
type=int,
help="""The default logging level in numeric values.""",
default=None,
)
parser.add_argument(
"--" + prefix_str + "logging.record_log",
action="store_true",
Expand All @@ -228,7 +237,7 @@ def add_args(cls, parser: argparse.ArgumentParser, prefix: str = None):
parser.add_argument(
"--" + prefix_str + "logging.logging_dir",
type=str,
help="Logging default root directory.",
help="""Logging default root directory.""",
default=default_logging_logging_dir,
)
except argparse.ArgumentError:
Expand Down

0 comments on commit ddf1535

Please sign in to comment.