-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding display of error though curses interface
- Loading branch information
1 parent
3197e10
commit 868c3ea
Showing
10 changed files
with
69 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
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,40 @@ | ||
"""Module that controls logging and error output""" | ||
|
||
import logging | ||
import io | ||
|
||
from calcure.configuration import cf | ||
|
||
|
||
class Error(): | ||
"""Error messages displayed to the user""" | ||
|
||
def __init__(self): | ||
self.buffer = io.StringIO() | ||
self.file = f"{cf.config_folder}/info.log" | ||
|
||
def get_error_text(self): | ||
"""Returns string with the text of the error""" | ||
return self.buffer.getvalue() | ||
|
||
def clear_buffer(self): | ||
"""Clear the buffer containing errors""" | ||
self.buffer = io.StringIO() | ||
|
||
@property | ||
def has_occured(self): | ||
"""Has any errors occured?""" | ||
return self.get_error_text() != "" | ||
|
||
|
||
# Initialise error: | ||
error = Error() | ||
|
||
# Start logging: | ||
logging.basicConfig(level=logging.INFO, | ||
format="[%(levelname)s] %(message)s", | ||
encoding='utf-8', | ||
handlers=[logging.FileHandler(error.file, 'w'), | ||
logging.StreamHandler(), | ||
logging.StreamHandler(error.buffer), | ||
]) |
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
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