-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic logging format and function
- Loading branch information
Justin Campbell
committed
Sep 14, 2020
1 parent
bf67aa7
commit 95c3684
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") | ||
|