mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-09-29 00:50:31 +00:00
Removed usage of logging.basicConfig
logging.basicConfig will change the configuration of the root logger and not the configuration of your own library logger. Since parsedmarc is a library, it should keep its logging configuration to its own logger, such that the logging configuration of applications using this library are not affected.
This commit is contained in:
@@ -38,12 +38,14 @@ from parsedmarc.utils import parse_email
|
|||||||
|
|
||||||
__version__ = "7.1.1"
|
__version__ = "7.1.1"
|
||||||
|
|
||||||
logging.basicConfig(
|
formatter = logging.Formatter(
|
||||||
format='%(levelname)8s:%(filename)s:%(lineno)d:'
|
fmt='%(levelname)8s:%(filename)s:%(lineno)d:%(message)s',
|
||||||
'%(message)s',
|
|
||||||
datefmt='%Y-%m-%d:%H:%M:%S')
|
datefmt='%Y-%m-%d:%H:%M:%S')
|
||||||
|
handler = logging.StreamHandler()
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
|
||||||
logger = logging.getLogger("parsedmarc")
|
logger = logging.getLogger("parsedmarc")
|
||||||
|
logger.addHandler(handler)
|
||||||
logger.debug("parsedmarc v{0}".format(__version__))
|
logger.debug("parsedmarc v{0}".format(__version__))
|
||||||
|
|
||||||
feedback_report_regex = re.compile(r"^([\w\-]+): (.+)$", re.MULTILINE)
|
feedback_report_regex = re.compile(r"^([\w\-]+): (.+)$", re.MULTILINE)
|
||||||
|
|||||||
@@ -578,14 +578,11 @@ def _main():
|
|||||||
else:
|
else:
|
||||||
opts.syslog_port = 514
|
opts.syslog_port = 514
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
|
||||||
logger.setLevel(logging.WARNING)
|
logger.setLevel(logging.WARNING)
|
||||||
|
|
||||||
if opts.verbose:
|
if opts.verbose:
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
if opts.debug:
|
if opts.debug:
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
if opts.log_file:
|
if opts.log_file:
|
||||||
fh = logging.FileHandler(opts.log_file)
|
fh = logging.FileHandler(opts.log_file)
|
||||||
|
|||||||
Reference in New Issue
Block a user