MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / get_logger

Function get_logger

monai/apps/utils.py:51–76  ·  view source on GitHub ↗

Get a `module_name` logger with the specified format and date format. By default, the logger will print to `stdout` at the INFO level. If `module_name` is `None`, return the root logger. `fmt` and `datafmt` are passed to a `logging.Formatter` object (https://docs.python.org/3/li

(
    module_name: str = "monai.apps",
    fmt: str = DEFAULT_FMT,
    datefmt: str | None = None,
    logger_handler: logging.Handler | None = None,
)

Source from the content-addressed store, hash-verified

49
50
51def get_logger(
52 module_name: str = "monai.apps",
53 fmt: str = DEFAULT_FMT,
54 datefmt: str | None = None,
55 logger_handler: logging.Handler | None = None,
56) -> logging.Logger:
57 """
58 Get a `module_name` logger with the specified format and date format.
59 By default, the logger will print to `stdout` at the INFO level.
60 If `module_name` is `None`, return the root logger.
61 `fmt` and `datafmt` are passed to a `logging.Formatter` object
62 (https://docs.python.org/3/library/logging.html#formatter-objects).
63 `logger_handler` can be used to add an additional handler.
64 """
65 adds_stdout_handler = module_name is not None and module_name not in logging.root.manager.loggerDict
66 logger = logging.getLogger(module_name)
67 logger.propagate = False
68 logger.setLevel(logging.INFO)
69 if adds_stdout_handler: # don't add multiple stdout or add to the root
70 handler = logging.StreamHandler(sys.stdout)
71 formatter = logging.Formatter(fmt=fmt, datefmt=datefmt)
72 handler.setFormatter(formatter)
73 logger.addHandler(handler)
74 if logger_handler is not None:
75 logger.addHandler(logger_handler)
76 return logger
77
78
79# apps module-level default logger

Callers 15

cuassertFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90
trt_compileFunction · 0.90
utils.pyFile · 0.90
monai_algo.pyFile · 0.90
data_analyzer.pyFile · 0.90
hpo_gen.pyFile · 0.90
bundle_gen.pyFile · 0.90
auto_runner.pyFile · 0.90
image_writer.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…