mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
--quiet means NOTICE level logging
and clean special log level code
This commit is contained in:
parent
de01700c54
commit
5654bcbeb8
@ -194,7 +194,7 @@ if __name__ == '__main__':
|
||||
args = arg_parser.parse_args(args=sys.argv[1:])
|
||||
|
||||
if args.trace:
|
||||
loglevel = warcprox.TRACE
|
||||
loglevel = logging.TRACE
|
||||
elif args.verbose:
|
||||
loglevel = logging.DEBUG
|
||||
else:
|
||||
|
@ -30,7 +30,7 @@ import logging
|
||||
import sys
|
||||
|
||||
logging.basicConfig(
|
||||
stream=sys.stdout, level=warcprox.TRACE,
|
||||
stream=sys.stdout, level=logging.TRACE,
|
||||
format='%(asctime)s %(process)d %(levelname)s %(threadName)s '
|
||||
'%(name)s.%(funcName)s(%(filename)s:%(lineno)d) %(message)s')
|
||||
|
||||
|
@ -90,8 +90,7 @@ def _send(self, data):
|
||||
# http_client.HTTPConnection.send = _send
|
||||
|
||||
logging.basicConfig(
|
||||
# stream=sys.stdout, level=logging.DEBUG, # level=warcprox.TRACE,
|
||||
stream=sys.stdout, level=warcprox.TRACE,
|
||||
stream=sys.stdout, level=logging.TRACE,
|
||||
format='%(asctime)s %(process)d %(levelname)s %(threadName)s '
|
||||
'%(name)s.%(funcName)s(%(filename)s:%(lineno)d) %(message)s')
|
||||
logging.getLogger("requests.packages.urllib3").setLevel(logging.WARN)
|
||||
|
@ -266,21 +266,21 @@ def timestamp14():
|
||||
return '{:%Y%m%d%H%M%S}'.format(now)
|
||||
|
||||
# monkey-patch log levels TRACE and NOTICE
|
||||
TRACE = 5
|
||||
logging.TRACE = (logging.NOTSET + logging.DEBUG) // 2
|
||||
def _logger_trace(self, msg, *args, **kwargs):
|
||||
if self.isEnabledFor(TRACE):
|
||||
self._log(TRACE, msg, args, **kwargs)
|
||||
if self.isEnabledFor(logging.TRACE):
|
||||
self._log(logging.TRACE, msg, args, **kwargs)
|
||||
logging.Logger.trace = _logger_trace
|
||||
logging.trace = logging.root.trace
|
||||
logging.addLevelName(TRACE, 'TRACE')
|
||||
logging.addLevelName(logging.TRACE, 'TRACE')
|
||||
|
||||
NOTICE = (logging.INFO + logging.WARN) // 2
|
||||
logging.NOTICE = (logging.INFO + logging.WARN) // 2
|
||||
def _logger_notice(self, msg, *args, **kwargs):
|
||||
if self.isEnabledFor(NOTICE):
|
||||
self._log(NOTICE, msg, args, **kwargs)
|
||||
if self.isEnabledFor(logging.NOTICE):
|
||||
self._log(logging.NOTICE, msg, args, **kwargs)
|
||||
logging.Logger.notice = _logger_notice
|
||||
logging.notice = logging.root.notice
|
||||
logging.addLevelName(NOTICE, 'NOTICE')
|
||||
logging.addLevelName(logging.NOTICE, 'NOTICE')
|
||||
|
||||
import warcprox.controller as controller
|
||||
import warcprox.playback as playback
|
||||
|
@ -299,9 +299,7 @@ class WarcproxController(object):
|
||||
status_info.update(self.proxy.status())
|
||||
|
||||
self.status_info = self.service_registry.heartbeat(status_info)
|
||||
self.logger.log(
|
||||
warcprox.TRACE, "status in service registry: %s",
|
||||
self.status_info)
|
||||
self.logger.trace('status in service registry: %s', self.status_info)
|
||||
|
||||
def start(self):
|
||||
with self._start_stop_lock:
|
||||
|
@ -290,11 +290,11 @@ def main(argv=None):
|
||||
args = parse_args(argv or sys.argv)
|
||||
|
||||
if args.trace:
|
||||
loglevel = warcprox.TRACE
|
||||
loglevel = logging.TRACE
|
||||
elif args.verbose:
|
||||
loglevel = logging.DEBUG
|
||||
elif args.quiet:
|
||||
loglevel = logging.WARNING
|
||||
loglevel = logging.NOTICE
|
||||
else:
|
||||
loglevel = logging.INFO
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user