FriendlyLog is a simple, colorful, user-friendly, thread-safe logger for Python
(2
and 3
).
pip install friendlylog
- Simple Logger
import logging
from friendlylog import simple_logger as log
# Anything above or including DEBUG will be logged.
log.setLevel(logging.DEBUG)
log.debug("debug message")
log.info("info message")
log.warning("warning message")
log.error("error message")
log.critical("critical message")
Will result in the following logs (test.py
is the name of the file):
[07-Oct-19 11:06:06.107 in test.py - <module>: 3] DEBUG: debug message
[07-Oct-19 11:06:06.107 in test.py - <module>: 4] INFO: info message
[07-Oct-19 11:06:06.107 in test.py - <module>: 5] WARNING: warning message
[07-Oct-19 11:06:06.107 in test.py - <module>: 6] ERROR: error message
[07-Oct-19 11:06:06.107 in test.py - <module>: 7] CRITICAL: critical message
- Colored Logger
import logging
from friendlylog import colored_logger as log
# Anything above or including DEBUG will be logged.
log.setLevel(logging.DEBUG)
log.debug("debug message")
log.info("info message")
log.warning("warning message")
log.error("error message")
log.critical("critical message")
Will result in the following logs (test.py
is the name of the file):
- Write the code for a new logger under
friendlylog
. It should export the following methods:setLevel(level)
debug(msg: string)
info(msg: string)
warning(msg: string)
error(msg: string)
critical(msg: string)
- Write unit tests with
>92%
coverage undertests
. You can run the tests locally using this command:bash run_tests.sh
. Make sure the new logger is thread-safe. Also, add a unit test that checks thread-safety; - Submit a pull-request with your changes.