Skip to content

Commit

Permalink
Changed logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
interkosmos committed Nov 19, 2016
1 parent 715f30a commit d85f8c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions openadms.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,20 @@ def stay_alive():
# '%(message)s'
fmt = '%(asctime)s - %(levelname)7s - %(module)12s - %(message)s'
formatter = logging.Formatter(fmt)
# Logging file handler.

# File handler.
fh = logging.handlers.RotatingFileHandler(LOG_FILE,
maxBytes=10485760, # 10 MB.
backupCount=1,
encoding='utf8')
fh.setLevel(level)
fh.setFormatter(formatter)

# Add handlers to logger.
logger.addHandler(fh)

date_fmt = '%Y-%m-%dT%H:%M:%S'
coloredlogs.install(level=level, fmt=fmt, datefmt=date_fmt)
coloredlogs.install(level=logging.DEBUG, fmt=fmt, datefmt=date_fmt)

# Use a signal handler to catch ^C and quit the program gracefully.
signal.signal(signal.SIGINT, signal_handler)
Expand Down

0 comments on commit d85f8c4

Please sign in to comment.