aboutsummaryrefslogtreecommitdiffstats
path: root/hdv/redfish/log_utils.py
blob: 996a1d12e9da9e64291c48fed30a82d960591081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)