-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a new logging & setup functions for standardization
- Loading branch information
1 parent
b4cf1b0
commit a4a9940
Showing
3 changed files
with
67 additions
and
3 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
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
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,35 @@ | ||
import logging | ||
import os | ||
|
||
""" | ||
This module provides logging utilities for the CLI. | ||
Note: we could potentially change the logging library or the way we log messages in the future. | ||
Therefore, it's a good idea to encapsulate logging-related code in a separate module. | ||
""" | ||
|
||
|
||
def setup_logging(): | ||
# TODO: consider supporting different ways of outputting logs | ||
# Note: by default, the log level is set to INFO | ||
log_level = os.getenv("LOG_LEVEL", "INFO").upper() | ||
logging.basicConfig(level=log_level, | ||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | ||
datefmt='%Y-%m-%d %H:%M:%S') | ||
|
||
|
||
def debug(message): | ||
logging.debug(message) | ||
|
||
|
||
def info(message): | ||
logging.info(message) | ||
|
||
|
||
def warning(message): | ||
logging.warning(message) | ||
|
||
|
||
def error(message): | ||
logging.error(message) | ||
# TODO: consider tracking errors to Mixpanel as well. |