diff options
author | 2016-11-10 10:59:26 +0800 | |
---|---|---|
committer | 2016-11-10 14:50:17 +0800 | |
commit | 9edb0f9e48cc923ed443d3d66886713cde9b628d (patch) | |
tree | 1463ca978963b6570ea143131d64d0b919a0b1f3 /utils/logger_utils.py | |
parent | 939299c36b3cf79f198d4a4849345eabd878973b (diff) |
Adjust folder structure
Note: this patchset may break existing features, but it will help
to accelerate the refactoring work.
JIRA: QTIP-131
Change-Id: Ie0cd9d185e6b02316878daef905e26f4e533a66b
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'utils/logger_utils.py')
-rw-r--r-- | utils/logger_utils.py | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/utils/logger_utils.py b/utils/logger_utils.py deleted file mode 100644 index e8817c3c..00000000 --- a/utils/logger_utils.py +++ /dev/null @@ -1,65 +0,0 @@ -############################################################################## -# Copyright (c) 2016 ZTE Corp and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Logging levels: -# Level Numeric value -# CRITICAL 50 -# ERROR 40 -# WARNING 30 -# INFO 20 -# DEBUG 10 -# NOTSET 0 -# -# Usage: -# from utils import logger_utils -# logger = logger_utils.QtipLogger(__file__).get -# logger.info("message to be shown with - INFO - ") -# logger.debug("message to be shown with - DEBUG -") -############################################################################## - -import logging -import os - - -class Logger(object): - file_path = '/var/log' - formatter = logging.Formatter('%(asctime)s - %(name)s - ' - '%(levelname)s - %(message)s') - - def __init__(self, logger_name): - - IF_DEBUG = os.getenv('IF_DEBUG') - - self.logger_name = logger_name - self.logger = logging.getLogger(logger_name) - self.logger.propagate = 0 - self.logger.setLevel(logging.DEBUG) - - ch = logging.StreamHandler() - ch.setFormatter(self.formatter) - if IF_DEBUG is not None and IF_DEBUG.lower() == "true": - ch.setLevel(logging.DEBUG) - else: - ch.setLevel(logging.INFO) - self.logger.addHandler(ch) - - hdlr = logging.FileHandler('%s/%s.log' % (self.file_path, logger_name)) - hdlr.setFormatter(self.formatter) - hdlr.setLevel(logging.DEBUG) - self.logger.addHandler(hdlr) - - @property - def get(self): - return self.logger - - -class QtipLogger(Logger): - file_path = '{}/qtip/logs'.format(os.environ['HOME']) - - def __init__(self, logger_name): - super(QtipLogger, self).__init__(logger_name) |