File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed
pytest_splunk_addon/helmut Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 22@author: Nicklas Ansman-Giertz
3344@since: 2011-11-23
5- """
5+ """
6+ from . import log
7+ log .setup_logger (debug = True )
Original file line number Diff line number Diff line change 99import logging .config
1010import os
1111from builtins import object
12- from logging import Formatter
12+ from logging import FileHandler , Formatter
1313
1414from future .utils import with_metaclass
1515
1616_LOG_FORMAT = "[%(asctime)s] %(levelname)s - %(name)s: %(message)s"
1717_DATE_FORMAT = "%Y-%m-%d %H:%M:%S.%f"
18- _FILE_NAME = ". .log"
18+ _FILE_NAME = "helmut .log"
1919
20-
21- def setup_logger ():
20+ def setup_logger (debug = False ):
2221 """
2322 Setups up the logging library
23+
24+ @param debug: If debug log messages are to be outputted
25+ @type debug: bool
2426 """
25- logging_conf = os .path .join (
26- os .path .dirname (os .path .abspath (__file__ )), "logging.conf"
27- )
28- logging .config .fileConfig (logging_conf )
27+ logger = logging .getLogger ('' )
28+ handler = FileHandler (filename = _FILE_NAME , mode = "w" )
29+ handler .setFormatter (HelmutFormatter (_LOG_FORMAT ))
30+ level = logging .INFO
31+ if debug :
32+ level = logging .DEBUG
33+ logger .addHandler (handler )
34+ logger .setLevel (level )
35+ logger .debug ('Logger: DEBUG logging is enabled' )
2936
3037
3138class HelmutFormatter (Formatter ):
You can’t perform that action at this time.
0 commit comments