aboutsummaryrefslogtreecommitdiffstats
path: root/hdv/redfish/log_utils.py
diff options
context:
space:
mode:
authorchenliangyjy <chenliangyjy@chinamobile.com>2020-05-08 12:38:30 +0800
committerchenliangyjy <chenliangyjy@chinamobile.com>2020-05-08 12:56:31 +0800
commit06bf8cf347d8af6740ab5df842abebf17dabac30 (patch)
tree9002d105565ddfd4d69d8cfcc2338746f941a008 /hdv/redfish/log_utils.py
parentae7bfeed7d4a02938068e4f72b962f56cdf9041c (diff)
migrate hdv code from cirv to subproject cirv-hdv project
Signed-off-by: chenliangyjy <chenliangyjy@chinamobile.com> Change-Id: Ieb02ccf45bdf7b0b46cb204c864a521d547a5231 Signed-off-by: chenliangyjy <chenliangyjy@chinamobile.com>
Diffstat (limited to 'hdv/redfish/log_utils.py')
-rw-r--r--hdv/redfish/log_utils.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/hdv/redfish/log_utils.py b/hdv/redfish/log_utils.py
new file mode 100644
index 0000000..996a1d1
--- /dev/null
+++ b/hdv/redfish/log_utils.py
@@ -0,0 +1,33 @@
+##############################################################################
+# Copyright (c) 2020 China Mobile Co.,Ltd 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
+##############################################################################
+"""
+define the LOGGER settings
+"""
+import logging
+import sys
+
+BASE_DIR = sys.path[0]
+LOG_FILE = BASE_DIR + "/" + "logs" + "/" + 'hdv.log'
+
+LOGGER = logging.getLogger("redfish")
+LOGGER.setLevel(logging.DEBUG)
+
+FORMATTER = logging.Formatter('%(asctime)s - %(filename)s[line:%(lineno)d] \
+ - %(funcName)s - %(levelname)s: %(message)s')
+
+FILE = logging.FileHandler(filename=LOG_FILE, mode='w')
+FILE.setLevel(logging.DEBUG)
+FILE.setFormatter(FORMATTER)
+
+CONSOLE = logging.StreamHandler()
+CONSOLE.setLevel(logging.DEBUG)
+CONSOLE.setFormatter(FORMATTER)
+
+LOGGER.addHandler(CONSOLE)
+LOGGER.addHandler(FILE)