-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from andreped/render-fix
Added logging and sidebar widgets with clear/toggle methods
- Loading branch information
Showing
3 changed files
with
140 additions
and
59 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,37 @@ | ||
import logging | ||
import sys | ||
|
||
|
||
def get_logger(): | ||
return logging.getLogger(__name__) | ||
|
||
|
||
def setup_logger(): | ||
# clear log | ||
file_to_delete = open("log.txt", "w") | ||
file_to_delete.close() | ||
|
||
file_handler = logging.FileHandler(filename="log.txt") | ||
stdout_handler = logging.StreamHandler(stream=sys.stdout) | ||
handlers = [file_handler, stdout_handler] | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, | ||
format="[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s", | ||
handlers=handlers, | ||
) | ||
|
||
return get_logger() | ||
|
||
|
||
def read_logs(): | ||
sys.stdout.flush() | ||
with open("log.txt", "r") as f: | ||
return f.read() | ||
|
||
|
||
def flush_logs(): | ||
sys.stdout.flush() | ||
# clear log | ||
file_to_delete = open("log.txt", "w") | ||
file_to_delete.close() |