MCPcopy
hub / github.com/OpenNMT/OpenNMT-py / init_logger

Function init_logger

onmt/utils/logging.py:10–35  ·  view source on GitHub ↗
(
    log_file=None,
    log_file_level=logging.NOTSET,
    rotate=False,
    log_level=logging.INFO,
)

Source from the content-addressed store, hash-verified

8
9
10def init_logger(
11 log_file=None,
12 log_file_level=logging.NOTSET,
13 rotate=False,
14 log_level=logging.INFO,
15):
16 log_format = logging.Formatter("[%(asctime)s %(levelname)s] %(message)s")
17 logger = logging.getLogger("onmt")
18 logger.setLevel(log_level)
19
20 console_handler = logging.StreamHandler()
21 console_handler.setFormatter(log_format)
22 logger.handlers = [console_handler]
23
24 if log_file and log_file != "":
25 if rotate:
26 file_handler = RotatingFileHandler(
27 log_file, maxBytes=1000000, backupCount=10
28 )
29 else:
30 file_handler = logging.FileHandler(log_file)
31 file_handler.setLevel(log_file_level)
32 file_handler.setFormatter(log_format)
33 logger.addHandler(file_handler)
34
35 return logger

Callers 15

mainFunction · 0.90
lora_weights.pyFile · 0.90
test_rouge.pyFile · 0.90
__init__Method · 0.90
__init__Method · 0.90
mainFunction · 0.90
spawned_inferFunction · 0.90
__init__Method · 0.90
_loggingMethod · 0.90
trainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected