aboutsummaryrefslogtreecommitdiffstats
path: root/hdv/redfish/log_utils.py
diff options
context:
space:
mode:
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)