MCPcopy Create free account
hub / github.com/adobe/Marinus / create_log

Method create_log

python3_cron_scripts/libs3/LoggingUtil.py:26–60  ·  view source on GitHub ↗

Steps: 1. Check for a customized config file as a parameter 2. If not 1, check for a "logging.conf" file 3. If not 1 or 2, set a basic logging format. :param level: This is the logging.LEVEL setting (optional) :param config_file: A YAML Pyth

(name, level=None, config_file=None)

Source from the content-addressed store, hash-verified

24class LoggingUtil:
25 @staticmethod
26 def create_log(name, level=None, config_file=None):
27 """
28 Steps:
29 1. Check for a customized config file as a parameter
30 2. If not 1, check for a "logging.conf" file
31 3. If not 1 or 2, set a basic logging format.
32
33 :param level: This is the logging.LEVEL setting (optional)
34 :param config_file: A YAML Python logging config file (optional)
35 :return: logger instance
36 """
37 if config_file is not None:
38 logging.config.fileConfig(config_file)
39 elif os.path.isfile("logging.conf"):
40 logging.config.fileConfig("logging.conf")
41 else:
42 # create formatter
43 logging.basicConfig(
44 format="[%(asctime)s] %(name)s {%(funcName)s:%(lineno)d} : %(levelname)s : %(message)s"
45 )
46
47 logger = logging.getLogger(name)
48
49 if level is not None:
50 logger.setLevel(level)
51 else:
52 try:
53 level = os.environ["LOG_LEVEL"]
54 except:
55 level = None
56
57 if level is not None:
58 logger.setLevel(int(level))
59
60 return logger

Callers 15

mainFunction · 0.80
mainFunction · 0.80
get_iblox_cname.pyFile · 0.80
mainFunction · 0.80
mainFunction · 0.80
get_iblox_aaaa.pyFile · 0.80
__init__Method · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected