Skip to content

Instantly share code, notes, and snippets.

@vivekjoshy
Created February 18, 2019 13:13
Show Gist options
  • Save vivekjoshy/4353436dc7be3eb9e64e3a8b6ac813fd to your computer and use it in GitHub Desktop.
Save vivekjoshy/4353436dc7be3eb9e64e3a8b6ac813fd to your computer and use it in GitHub Desktop.
VerboseLogs created by daegontaven - https://repl.it/@daegontaven/VerboseLogs
LOG_FORMAT = "%(asctime)s %(name)-18s %(levelname)-8s %(message)s"
DATE_FORMAT = "[%Y-%m-%d %H:%M:%S %z]"
MAIN_FIELD_STYLES = {
'asctime': {
'color': 'green'
},
'levelname': {
'color': 'black',
'bold': True
},
'name': {
'color': 'magenta'
}
}
LIB_FIELD_STYLES = {
**MAIN_FIELD_STYLES,
'name': {
'color': 'blue'
}
}
import logging
import coloredlogs
from verboselogs import VerboseLogger
from config import *
logging.setLoggerClass(VerboseLogger)
main_logger = logging.getLogger('main')
coloredlogs.install(
logger=main_logger,
fmt=LOG_FORMAT,
datefmt=DATE_FORMAT,
field_styles=MAIN_FIELD_STYLES
)
lib_logger = logging.getLogger('lib')
coloredlogs.install(
logger=lib_logger,
fmt=LOG_FORMAT,
datefmt=DATE_FORMAT,
field_styles=LIB_FIELD_STYLES
)
coloredlogs.set_level(logging.DEBUG) # Causes Duplication
main_logger.warning("Main: Warning")
main_logger.info("Main: Info")
main_logger.debug("Main: Debug")
lib_logger.warning("Lib: Warning")
lib_logger.info("Lib: Info")
lib_logger.debug("Lib: Debug")
if __name__ == "__main__":
pass
verboselogs==1.7
coloredlogs==10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment