utils: always enable microsecond logging.

It's too useful, and the logs are fairly out of control already, may as
well just capture everything in the first pass.
pull/295/head
David Wilson 7 years ago
parent 7697861011
commit 0eb77b5f7c

@ -41,7 +41,7 @@ class Handler(logging.Handler):
"""
def __init__(self, display, normal_method):
logging.Handler.__init__(self)
self.formatter = mitogen.utils.log_get_formatter(usec=True)
self.formatter = mitogen.utils.log_get_formatter()
self.display = display
self.normal_method = normal_method

@ -1323,7 +1323,7 @@ A random assortment of utility functions useful on masters and children.
OS X bundles some ancient version of the :py:mod:`six` module.
.. currentmodule:: mitogen.utils
.. function:: log_to_file (path=None, io=False, usec=False, level='INFO')
.. function:: log_to_file (path=None, io=False, level='INFO')
Install a new :py:class:`logging.Handler` writing applications logs to the
filesystem. Useful when debugging slave IO problems.
@ -1339,10 +1339,6 @@ A random assortment of utility functions useful on masters and children.
If :data:`True`, include extremely verbose IO logs in the output.
Useful for debugging hangs, less useful for debugging application code.
:parm bool usec:
If :data:`True`, include microsecond timestamps. This greatly helps
when debugging races and similar determinism issues.
:param str level:
Name of the :py:mod:`logging` package constant that is the minimum
level to log at. Useful levels are ``DEBUG``, ``INFO``, ``WARNING``,

@ -155,10 +155,6 @@ Logging Environment Variables
produces verbose records of any IO interaction, which is useful for
debugging hangs and deadlocks.
``MITOGEN_LOG_USEC``
If present, forces microsecond-level timestamps for any call to
:py:func:`mitogen.utils.log_to_file`.
Logging Records

@ -56,19 +56,15 @@ def _formatTime(record, datefmt=None):
return dt.strftime(datefmt)
def log_get_formatter(usec=False):
usec = ('MITOGEN_LOG_USEC' in os.environ) or usec
datefmt = '%H:%M:%S'
if usec:
datefmt += '.%f'
def log_get_formatter():
datefmt = '%H:%M:%S.%f'
fmt = '%(asctime)s %(levelname).1s %(name)s: %(message)s'
formatter = logging.Formatter(fmt, datefmt)
formatter.formatTime = _formatTime
return formatter
def log_to_file(path=None, io=False, usec=False, level='INFO'):
def log_to_file(path=None, io=False, level='INFO'):
log = logging.getLogger('')
if path:
fp = open(path, 'w', 1)
@ -86,7 +82,7 @@ def log_to_file(path=None, io=False, usec=False, level='INFO'):
log.setLevel(level)
handler = logging.StreamHandler(fp)
handler.formatter = log_get_formatter(usec=usec)
handler.formatter = log_get_formatter()
log.handlers.insert(0, handler)

Loading…
Cancel
Save