Skip to content

Commit

Permalink
Add basic logging format and function
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Sep 14, 2020
1 parent bf67aa7 commit 95c3684
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions utils/venv-manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Allows for creating, deleting and removing Python virtual environments in webqueue2
Examples:
Create a virtual environment:
$ venv-manager.py [-c | --create]
Delete a virtual environment:
$ venv-manager.py [-d | --delete]
Reset a virtual environment:
$ venv-manager.py [-r | --reset]
"""

import logging


################################################################################
# Configuration
################################################################################

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

# See: https://docs.python.org/3/library/logging.html#logrecord-attributes
log_message_format = "%(asctime)s %(name)s : [%(levelname)s] %(message)s"
# See: https://docs.python.org/3.6/library/time.html#time.strftime
log_time_format = "%b %d %Y %H:%M:%S"
log_formatter = logging.Formatter(log_message_format, log_time_format)

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



if __name__ == "__main__":
logger.debug("This is a debug message.")
logger.info("This is an info message.")
logger.warning("This is a warning message.")
logger.error("This is an error message.")
logger.critical("This is a critical message.")

0 comments on commit 95c3684

Please sign in to comment.