MHLib.jl icon indicating copy to clipboard operation
MHLib.jl copied to clipboard

Logging

Open jamesmulhern opened this issue 1 year ago • 2 comments

In this pull request I have added basic logging functionality to the MHLib package. I have implemented the following high level changes.

  1. Created a Log.jl file and module. Also implemented a very simple custom logging method
  2. Moved all printing/logging methods from Schedulers.jl to Log.jl
  3. Updated the Settings.jl settings_cfg argument table to include an additional parameter --ofile
  4. Added a logger::AbstractLogger field to the Scheduler struct
  5. Small bug fix related to double inclusion of --seed and --ifile when using the all_settings_cfgs as an input to parse_settings!()

In detail the logging process works as follows.

  • If the user does not set the --ofile argument than no log file is created. Print statements are still sent to stdout as is normal
  • If the user does set the --ofile argument then by default a simple logger is created with the get_logger() method. This logger is an instance of the MHLogger type that simply writes the message directly to a file with no additional information.
  • If the user overloads the get_logger method than any logger can be returned. This allows for the user to create their own custom loggers that save the solution data in different ways.

Notes:

  • No changes were made to the format or content of the output messages
  • All tests run and pass
  • Unclear how to benchmark the effect on performance. All methods are created with well defined types, so should be type stable.

jamesmulhern avatar Jun 12 '24 08:06 jamesmulhern

Dear James, many thanks for this pull request, which I appreciate much! Just give me some time please to look through it, in particular as I currently have a rather full schedule.

graidl avatar Jun 13 '24 06:06 graidl

No rush, when you have a chance take a look. I can make any changes you recommend.

jamesmulhern avatar Jun 13 '24 06:06 jamesmulhern

Thank's for the contribution!

graidl avatar Oct 02 '24 16:10 graidl