mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-05-21 19:35:37 +00:00
added option to redirect log into a specified file
This commit is contained in:
@@ -223,6 +223,8 @@ def _main():
|
||||
help="only print errors and warnings")
|
||||
arg_parser.add_argument("--debug", action="store_true",
|
||||
help="print debugging information")
|
||||
arg_parser.add_argument("--log-file", default=None,
|
||||
help="redirect logging to file")
|
||||
arg_parser.add_argument("-v", "--version", action="version",
|
||||
version=__version__)
|
||||
|
||||
@@ -237,6 +239,11 @@ def _main():
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
if args.log_file:
|
||||
fh = logging.FileHandler(args.log_file)
|
||||
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
||||
fh.setFormatter(formatter)
|
||||
logger.addHandler(fh)
|
||||
if args.host is None and len(args.file_path) == 0:
|
||||
arg_parser.print_help()
|
||||
exit(1)
|
||||
|
||||
Reference in New Issue
Block a user