forked from smart-on-fhir/fhir-parser
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlogger.py
30 lines (23 loc) · 780 Bytes
/
logger.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
# desired log level
log_level = logging.DEBUG
# we try to setup a colored logger, used throughout fhir-generator
# use "logger.logger.log()"
logging.root.setLevel(log_level)
try:
from colorlog import ColoredFormatter
logfmt = (
" %(log_color)s%(levelname)-8s%(reset)s | %(log_color)s%(message)s%(reset)s"
)
formatter = ColoredFormatter(logfmt)
stream = logging.StreamHandler()
stream.setLevel(log_level)
stream.setFormatter(formatter)
logger = logging.getLogger("fhirparser")
logger.setLevel(log_level)
logger.addHandler(stream)
except Exception as e:
logging.info('Install "colorlog" to enable colored log messages')
logger = logging.getLogger("fhirparser")