-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
31 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 |
---|---|---|
@@ -1,32 +1 @@ | ||
""" Simulator package. View README """ | ||
|
||
import datetime | ||
import logging | ||
import sys | ||
|
||
log = logging.getLogger(__name__) | ||
log.setLevel(logging.DEBUG) | ||
# Create handlers for logging to the standard output and a file | ||
stdoutHandler = logging.StreamHandler(stream=sys.stdout) | ||
fileHandler = logging.FileHandler(f"bcipy/simulator/sim_output_{datetime.datetime.now()}.log") | ||
|
||
# Set the log levels on the handlers | ||
stdoutHandler.setLevel(logging.INFO) | ||
fileHandler.setLevel(logging.DEBUG) | ||
|
||
# Create a log format using Log Record attributes | ||
fmt_file = logging.Formatter( | ||
"%(levelname)s | %(filename)s:%(lineno)s >> %(message)s" | ||
) | ||
|
||
fmt = logging.Formatter( | ||
"%(levelname)s >> %(message)s" | ||
) | ||
|
||
# Set the log format on each handler | ||
stdoutHandler.setFormatter(fmt) | ||
fileHandler.setFormatter(fmt_file) | ||
|
||
# Add each handler to the Logger object | ||
log.addHandler(stdoutHandler) | ||
log.addHandler(fileHandler) |
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