From 70161338e689e1a8631df99308d88dacac25fb22 Mon Sep 17 00:00:00 2001 From: Darius Morawiec Date: Sun, 13 Jan 2019 23:08:46 +0100 Subject: [PATCH] release/0.7.0: Add logging class --- sklearn_porter/utils/Logging.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sklearn_porter/utils/Logging.py diff --git a/sklearn_porter/utils/Logging.py b/sklearn_porter/utils/Logging.py new file mode 100644 index 00000000..884db606 --- /dev/null +++ b/sklearn_porter/utils/Logging.py @@ -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)