Created
February 18, 2019 13:13
-
-
Save vivekjoshy/4353436dc7be3eb9e64e3a8b6ac813fd to your computer and use it in GitHub Desktop.
VerboseLogs created by daegontaven - https://repl.it/@daegontaven/VerboseLogs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
verboselogs==1.7 | |
coloredlogs==10.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment