Skip to content
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

logging #125

Merged
merged 10 commits into from
Aug 2, 2023
Merged

logging #125

merged 10 commits into from
Aug 2, 2023

Conversation

stefansc1
Copy link
Collaborator

Add logging to file in addition to console output. Can be configured:

  • loglevel: what (minimum) type of messages to log. Useful: DEBUG, INFO, WARN and ERROR. Defaults to INFO (includes WARN and ERROR, excludes DEBUG). Consult --help or logging docu for all options.
  • logfile: name of logfile that is written to output_directory. Defaults to [timestamp].log. Can be set to null to disable file logging.

All warnings are written to log as well.
If there is an exception during a mode, it is written to the logfile (with traceback), a plot is generated (if there is anything to plot) and the program continues with the next mode (if possible).

stefan.schirmeister added 4 commits June 1, 2023 10:08
If there is an exception while running a mode, print to log, generate plot (if there is anything to plot) and continue with next mode.
ebus_toolbox/__main__.py Show resolved Hide resolved
print(f"Writing log to {log_path}")
log_handlers.append(logging.FileHandler(log_path))
logging.basicConfig(
level=vars(logging)[args.loglevel],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could splitting file and stream logging levels be useful?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a question for @j-brendel. In my opinion, it should not be split, as both should display the same (the file log is just the captured console log). And it is more difficult to separate these two.

Copy link
Collaborator

@j-brendel j-brendel Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this issue here: #127

ebus_toolbox/optimization.py Outdated Show resolved Hide resolved
ebus_toolbox/report.py Show resolved Hide resolved
ebus_toolbox/schedule.py Outdated Show resolved Hide resolved
ebus_toolbox/util.py Show resolved Hide resolved
- logging.warning instead of logging.warn (deprecated)
- correct spelling of SpiceEV
- remove DEBUG logging of matplotlib
- move logging setup to util
@j-brendel j-brendel mentioned this pull request Jun 7, 2023
17 tasks
Copy link
Collaborator

@j-brendel j-brendel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor remark. The functionality is fine to me, having noted issue #127

@@ -87,6 +87,15 @@ default_buffer_time_opps = 0
# Options: HV, HV/MV, MV, MV/LV, LV (default: MV)
default_voltage_level = "MV"

##### LOGGING #####
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file created has ANSI encoding on my PC. Is it possible to change to UTF-8 (hardcoded?)

@stefansc1 stefansc1 merged commit fabff0b into dev Aug 2, 2023
6 checks passed
@stefansc1 stefansc1 deleted the feature/logging branch August 2, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants