Skip to content

Commit

Permalink
Add file handler to logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Sep 14, 2020
1 parent 95c3684 commit 6393ef3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ yarn-error.log*

# Python Files
/api/venv
__pycache__/
__pycache__/
venv-manager.log
9 changes: 7 additions & 2 deletions utils/venv-manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
################################################################################

# Configure the logger
logger = logging.getLogger("venv-manager")
logger_name = "venv-manager"
logger = logging.getLogger(logger_name)
logger.setLevel(logging.DEBUG)

# See: https://docs.python.org/3/library/logging.html#logrecord-attributes
Expand All @@ -30,8 +31,12 @@

stream_handler = logging.StreamHandler()
stream_handler.setFormatter(log_formatter)
logger.addHandler(stream_handler)

file_handler = logging.FileHandler(f'{logger_name}.log')
file_handler.setFormatter(log_formatter)

logger.addHandler(stream_handler)
logger.addHandler(file_handler)


if __name__ == "__main__":
Expand Down

0 comments on commit 6393ef3

Please sign in to comment.