mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
Merge pull request #116 from vbanos/logging-config-file
Add option to load logging conf from YAML file
This commit is contained in:
commit
df7b46d94f
1
setup.py
1
setup.py
@ -33,6 +33,7 @@ deps = [
|
|||||||
'PySocks>=1.6.8',
|
'PySocks>=1.6.8',
|
||||||
'cryptography>=2.3',
|
'cryptography>=2.3',
|
||||||
'idna>=2.5',
|
'idna>=2.5',
|
||||||
|
'PyYAML>=5.1',
|
||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
|
@ -30,6 +30,7 @@ except ImportError:
|
|||||||
import Queue as queue
|
import Queue as queue
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import logging.config
|
||||||
import sys
|
import sys
|
||||||
import hashlib
|
import hashlib
|
||||||
import argparse
|
import argparse
|
||||||
@ -39,6 +40,7 @@ import traceback
|
|||||||
import signal
|
import signal
|
||||||
import threading
|
import threading
|
||||||
import certauth.certauth
|
import certauth.certauth
|
||||||
|
import yaml
|
||||||
import warcprox
|
import warcprox
|
||||||
import doublethink
|
import doublethink
|
||||||
import cryptography.hazmat.backends.openssl
|
import cryptography.hazmat.backends.openssl
|
||||||
@ -239,6 +241,9 @@ def _build_arg_parser(prog='warcprox', show_hidden=False):
|
|||||||
arg_parser.add_argument(
|
arg_parser.add_argument(
|
||||||
'--trace', dest='trace', action='store_true',
|
'--trace', dest='trace', action='store_true',
|
||||||
help='very verbose logging')
|
help='very verbose logging')
|
||||||
|
arg_parser.add_argument(
|
||||||
|
'--logging-conf-file', dest='logging_conf_file', default=None,
|
||||||
|
help=('reads logging configuration from a YAML file'))
|
||||||
arg_parser.add_argument(
|
arg_parser.add_argument(
|
||||||
'--version', action='version',
|
'--version', action='version',
|
||||||
version="warcprox {}".format(warcprox.__version__))
|
version="warcprox {}".format(warcprox.__version__))
|
||||||
@ -302,6 +307,11 @@ def main(argv=None):
|
|||||||
'%(asctime)s %(process)d %(levelname)s %(threadName)s '
|
'%(asctime)s %(process)d %(levelname)s %(threadName)s '
|
||||||
'%(name)s.%(funcName)s(%(filename)s:%(lineno)d) %(message)s'))
|
'%(name)s.%(funcName)s(%(filename)s:%(lineno)d) %(message)s'))
|
||||||
|
|
||||||
|
if args.logging_conf_file:
|
||||||
|
with open(args.logging_conf_file, 'r') as fd:
|
||||||
|
conf = yaml.safe_load(fd)
|
||||||
|
logging.config.dictConfig(conf)
|
||||||
|
|
||||||
# see https://github.com/pyca/cryptography/issues/2911
|
# see https://github.com/pyca/cryptography/issues/2911
|
||||||
cryptography.hazmat.backends.openssl.backend.activate_builtin_random()
|
cryptography.hazmat.backends.openssl.backend.activate_builtin_random()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user