Skip to content

Instantly share code, notes, and snippets.

@jonmorehouse
Created October 5, 2016 19:52
Show Gist options
  • Save jonmorehouse/55a5971af89c1e2fb68f768e4bf7869e to your computer and use it in GitHub Desktop.
Save jonmorehouse/55a5971af89c1e2fb68f768e4bf7869e to your computer and use it in GitHub Desktop.
import logging
def info(msg, **kwargs):
_log(msg, logging.info, kwargs)
def warning(msg, **kwargs):
_log(msg, logging.warning, kwargs)
def error(msg, **kwargs):
_log(msg, logging.error, kwargs)
def critical(msg, **kwargs):
_log(msg, logging.critical, kwargs)
def exception(msg, **kwargs):
_log(msg, logging.exception, kwargs)
def _log(msg, method, kwargs):
banned = ('exc_info', 'stack_info', 'extra')
for k, v in kwargs.items():
if k not in banned:
msg += k + "=" + v
del kwargs[k]
method(msg, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment