Skip to content

Commit

Permalink
release/0.7.0: Add logging class
Browse files Browse the repository at this point in the history
  • Loading branch information
nok committed Jan 13, 2019
1 parent 3c3c0fa commit 7016133
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sklearn_porter/utils/Logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-

import logging


LOGGING_FORMAT = '%(name)-12s: %(levelname)-8s %(message)s'


class Logging(object):

@staticmethod
def get_logger(name, level=0):
"""Setup a logging instance"""
console = logging.StreamHandler()
level = [logging.NOTSET, logging.ERROR, logging.WARN, logging.INFO,
logging.DEBUG][level]
console.setLevel(level)
formatter = logging.Formatter(LOGGING_FORMAT)
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
return logging.getLogger(name)

0 comments on commit 7016133

Please sign in to comment.