-
Notifications
You must be signed in to change notification settings - Fork 2
#490: In CommandLogHandler suffixed newline, flushed logfile and added timestamp #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#490: In CommandLogHandler suffixed newline, flushed logfile and added timestamp #499
Conversation
This reverts commit 053d00f.
) | ||
|
||
|
||
def test_new_line(tmp_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably need another test, that checks if the timestamp gets prepended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
log_handler.handle_log_line("log line 1") | ||
log_handler.handle_log_line("log line 2") | ||
with open(log_file_path) as log_file: | ||
line_count = sum(1 for line in log_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting construction, I like it; this actually would stream the file , which is good for large files. Maybe a bit overkill, but perfectly ok.
timestamp = cur_time.strftime("%H.%M.%S") | ||
msecs = str(int(cur_time.microsecond / 1000)) | ||
usecs = str(int(cur_time.microsecond % 1000)) | ||
return timestamp + "." + msecs + "." + usecs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timestamp = cur_time.strftime("%H.%M.%S") | |
msecs = str(int(cur_time.microsecond / 1000)) | |
usecs = str(int(cur_time.microsecond % 1000)) | |
return timestamp + "." + msecs + "." + usecs | |
timestamp = cur_time.strftime("%H.%M.%S.%f") | |
return timestamp |
I don't think we need to split the microseconds more. https://docs.python.org/3.10/library/datetime.html#strftime-strptime-behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the static method timestamp_for_logging() and used the default 6 digits microseconds
… timestamp is prepended
test/unit/test_log_newline.py
Outdated
log_handler.handle_log_line("log line 1") | ||
with open(log_file_path) as log_file: | ||
first_line = log_file.readline() | ||
assert re.match(pattern, first_line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert re.match(pattern, first_line) | |
assert re.match(pattern, first_line), f"{first_line} does not match {pattern}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have the regex_matcher already in this project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, we have,
class regex_matcher: |
|
Fixes #490