-
Notifications
You must be signed in to change notification settings - Fork 13
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
Implements #11 - JSONL logging instead of printing to stdout #106
Conversation
… present: 1. added logger at module level 2. replace print statement by correspoding logging statement: info, warning, error and debug (for commented prints)
1. another demo parser?? 2. get_result method when using cached results
…onsole only as per cmd parameter (configured by default to WARNING). File logging rules: - JSONL format. Note: Still breaks if double quotes added to the message. - File per execution (analyse, parse), per case.
Cool ! I notice there is quite some redundant code in all the parser/analyser files. |
it would, if we would not use static methods :) because that was my first approach... and I don't dare to go for such code revamp |
We can drop the static methods, that would be cleaner, no? |
I have got another idea, so that we do not even drop the static methods. I move all the initialisation code to utils/logger.py (instead of jsonlogger.py as it is now) and in the rest of the files, we just do an import from that logger.py from sysdiagnose.utils.logger import logger Where logger, logger = blablablabla That would also be a clean option, wouldn't it? What do you think? https://stackoverflow.com/questions/50391429/logging-in-classes-python |
…sysdiagnose into issue-11-logging
…tements back from merge from main.
src/sysdiagnose/main.py
Outdated
for case_id in case_ids: | ||
# Handle file logging | ||
time_str = time.strftime("%Y%m%dT%H%M%S") | ||
filename = f"{time_str}-parse-{case_id}.jsonl" |
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.
The file is saved in the parsed_data_folder
. Is there real value in adding the case_id
in the filename?
I would propose to use something like log-{time_str}-parse.jsonl
instead or {time_str}-log-parse.jsonl
.
Second question: is it appending logs to that file? So if a user runs parser X, and later on parser Y the logs are appended?
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.
If you run parse/analyse all, all logs are appended to the same 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.
See 62354a5
…nd removing case_id from the filename.
…parameter resides. That is, available to all modes
…onstrate how-to log
Added logging capabilities to JSONL.
Caveat: still missing the result/status of the parser/analyser when logging.