Also send log messages to a real log file, at .vigil/.log.
This commit is contained in:
parent
5d1c124d8e
commit
9b1bfc5dd0
2 changed files with 6 additions and 3 deletions
8
vigil
8
vigil
|
|
@ -473,6 +473,7 @@ class Log:
|
|||
|
||||
GREY_BOLD_STYLE = termstr.CharStyle(termstr.Color.grey_100, is_bold=True)
|
||||
GREEN_STYLE = termstr.CharStyle(termstr.Color.green)
|
||||
LOG_PATH = os.path.join(_CACHE_PATH, ".log")
|
||||
|
||||
def __init__(self, appearance_changed_event):
|
||||
self._appearance_changed_event = appearance_changed_event
|
||||
|
|
@ -489,9 +490,10 @@ class Log:
|
|||
message = termstr.TermStr(message, char_style)
|
||||
timestamp = (time.strftime("%H:%M:%S", time.localtime())
|
||||
if timestamp is None else timestamp)
|
||||
label = fill3.Text(termstr.TermStr(timestamp, Log.GREY_BOLD_STYLE) +
|
||||
" " + message)
|
||||
self.widget.append(label)
|
||||
line = termstr.TermStr(timestamp, Log.GREY_BOLD_STYLE) + " " + message
|
||||
self.widget.append(fill3.Text(line))
|
||||
with open(Log.LOG_PATH, "a") as log_file:
|
||||
print(line, file=log_file)
|
||||
self.widget.widgets = self.widget[-200:]
|
||||
self._appearance_cache = None
|
||||
self._appearance_changed_event.set()
|
||||
|
|
|
|||
|
|
@ -247,6 +247,7 @@ class MainTestCase(unittest.TestCase):
|
|||
vigil.main(temp_dir, is_being_tested=True)
|
||||
self.assertTrue(os.path.exists(".vigil/.summary.pickle"))
|
||||
self.assertTrue(os.path.exists(".vigil/.creation-time"))
|
||||
self.assertTrue(os.path.exists(".vigil/.log"))
|
||||
self.assertTrue(os.path.exists(".vigil/foo-metadata"))
|
||||
self.assertEqual(_mount_total(), mount_total)
|
||||
self.assertEqual(_tmp_total(), tmp_total)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue