lazy_logger is a tool helping you to easily use Python's logging
module by Python's print
function.
- Git 1.8+
- Python 3.x
by pip
pip install lazy_logger
# demo.py
import lazy_logger
import sys
logger = lazy_logger.get_logger()
lazy_logger.log_to_console(logger)
lazy_logger.log_to_rotated_file(logger)
@logger.patch
def main():
print('Hello World!') # expect acting as logger
print('Hello stdout!', file=sys.stdout) # expect acting as normal print
if __name__ == '__main__':
main()
@logger.patch
: decorator makingprint
without file argument to logger which you configured belowlog_to_console()
: set logger for sending the message to stderrlog_to_rotated_file()
: set logger for saving the message in file (default: log.out) and rotating at same timelog_to_syslogd():
set logger for sending data to sysemd
py.test --capture=sys
- tim(@timtan)
- WendellLiu(@WendellLiu)
- jackpan(@jackklpan)
- Jason(@chairco)