-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a correct and clean logging configuration
- Loading branch information
1 parent
e37f8d9
commit 0eef9ad
Showing
6 changed files
with
72 additions
and
7 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,25 @@ | ||
import logging | ||
|
||
VERBOSE_LOG_FORMAT = "[%(asctime)s] %(pathname)s:%(lineno)d: %(message)s" | ||
|
||
|
||
def setup_logging(verbose=False, debug=False): | ||
logger = logging.getLogger("balto") | ||
logger.setLevel(logging.DEBUG) | ||
|
||
# Reset handlers | ||
logger.handlers = [] | ||
|
||
# Add handler | ||
console = logging.StreamHandler() | ||
|
||
if debug is False: | ||
console.setLevel(logging.INFO) | ||
else: | ||
console.setLevel(logging.DEBUG) | ||
|
||
if verbose is True: | ||
formatter = logging.Formatter(VERBOSE_LOG_FORMAT) | ||
console.setFormatter(formatter) | ||
|
||
logger.addHandler(console) |
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
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