mabarnes / moment_kinetics

Other
2 stars 4 forks source link

Per-process logging #204

Open johnomotani opened 2 months ago

johnomotani commented 2 months ago

It would be nice to write printed messages to log files as well as the terminal. If we have 1 log file for each process, we can see which process each message actually came from, which could be useful for debugging, etc.

One option could be to use the Logging module (https://docs.julialang.org/en/v1/stdlib/Logging/) and define a 'custom logger' that prints the message both to stdout and to a file (that can be named when the logger is created). We'd replace println(foo) with @info foo (or possibly @warn foo or @debug foo...).

It should also be possible to have messages that are printed to the log files by all processes, but only printed to the terminal by the root (MPI rank-0) process, either as the default setting (the custom Logger could check whether it is on rank-0 or not), or with a custom macro like @info_root which we could copy/modify from @info.