Skip to content

Instantly share code, notes, and snippets.

@jmetzz
Created January 9, 2019 10:15
Show Gist options
  • Save jmetzz/d324e90a7af38a6589f462cf8064ef45 to your computer and use it in GitHub Desktop.
Save jmetzz/d324e90a7af38a6589f462cf8064ef45 to your computer and use it in GitHub Desktop.
python color log configuration
def configure_colored_logging(loglevel):
import coloredlogs
field_styles = coloredlogs.DEFAULT_FIELD_STYLES.copy()
field_styles['asctime'] = {}
level_styles = coloredlogs.DEFAULT_LEVEL_STYLES.copy()
level_styles['debug'] = {}
coloredlogs.install(
level=loglevel,
use_chroot=False,
fmt='%(asctime)s %(levelname)-8s %(name)s - %(message)s',
level_styles=level_styles,
field_styles=field_styles)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment