Skip to content

Instantly share code, notes, and snippets.

@PFython
Last active October 25, 2022 18:02
Show Gist options
  • Save PFython/01e81703275d94b9cf7771aee9f81e63 to your computer and use it in GitHub Desktop.
Save PFython/01e81703275d94b9cf7771aee9f81e63 to your computer and use it in GitHub Desktop.
Create a logger for every Module
"""
Create one log file per module using __file__ for the main filename.
"""
from log2d import Log, Path
if __name__ == '__main__':
log = Log(Path(__file__).stem, to_file=True).logger
# TEST
file_name = Path(__file__).name
log.critical(f'critical message from: {file_name}')
log.error(f'error message from: {file_name}')
log.warning(f'new warning message from: {file_name}')
log.info(f'info message from: {file_name}')
log.debug(f'debug message from: {file_name}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment