Make log_to_file accept string level rather than logging package constant

Saves an import, pain in the ass to type all the time.
wip-fakessh-exit-status
David Wilson 7 years ago
parent a9387b0504
commit 750e9fab24

@ -27,7 +27,7 @@ def log_to_tmp():
log_to_file(path='/tmp/mitogen.%s.log' % (os.getpid(),))
def log_to_file(path=None, io=True, level=logging.INFO):
def log_to_file(path=None, io=True, level='INFO'):
"""Install a new :py:class:`logging.Handler` writing applications logs to
the filesystem. Useful when debugging slave IO problems."""
log = logging.getLogger('')
@ -37,6 +37,7 @@ def log_to_file(path=None, io=True, level=logging.INFO):
else:
fp = sys.stderr
level = getattr(logging, level, logging.INFO)
log.setLevel(level)
if io:
logging.getLogger('mitogen.io').setLevel(level)

@ -27,7 +27,7 @@ def serve_django_app(settings_name):
def main(broker):
import logging
mitogen.utils.log_to_file(level=logging.INFO, io=False)
mitogen.utils.log_to_file(io=False)
context = mitogen.master.connect(broker)
context.call(os.chdir, '/')
#context.call(mitogen.utils.log_to_file, '/tmp/log')

@ -7,7 +7,7 @@ import mitogen.utils
@mitogen.utils.run_with_router
def main(router):
mitogen.utils.log_to_file(io=False, level=logging.INFO)
mitogen.utils.log_to_file(io=False)
child1 = router.ssh(name='u', hostname='u')
child2 = router.sudo(
username='sudo_pw_test',

Loading…
Cancel
Save