forked from mlflow/mlflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging_utils.py
43 lines (36 loc) · 1.14 KB
/
logging_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from __future__ import print_function
import sys
import logging
import logging.config
# Logging format example:
# 2018/11/20 12:36:37 INFO mlflow.sagemaker: Creating new SageMaker endpoint
LOGGING_LINE_FORMAT = "%(asctime)s %(levelname)s %(name)s: %(message)s"
LOGGING_DATETIME_FORMAT = "%Y/%m/%d %H:%M:%S"
def _configure_mlflow_loggers(root_module_name):
logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'mlflow_formatter': {
'format': LOGGING_LINE_FORMAT,
'datefmt': LOGGING_DATETIME_FORMAT,
},
},
'handlers': {
'mlflow_handler': {
'level': 'INFO',
'formatter': 'mlflow_formatter',
'class': 'logging.StreamHandler',
'stream': sys.stderr,
},
},
'loggers': {
root_module_name: {
'handlers': ['mlflow_handler'],
'level': 'INFO',
'propagate': False,
},
},
})
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)