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

Investigate improved logger #718

Open
cwschilly opened this issue Jan 20, 2025 · 4 comments
Open

Investigate improved logger #718

cwschilly opened this issue Jan 20, 2025 · 4 comments
Assignees

Comments

@cwschilly
Copy link
Collaborator

cwschilly commented Jan 20, 2025

Remove dependency on sbdlog and determine best approach at implementing a new logger.

Some considerations:

  • The new logger should not depend on an external library
  • There should be different levels, like always-on numerical output from the solvers, or optionally-enabled run information or debug prints
  • There should be an option to write the log to a file
@cwschilly cwschilly self-assigned this Jan 20, 2025
@cwschilly
Copy link
Collaborator Author

cwschilly commented Jan 20, 2025

Initial findings on pressio logging

Existing levels

PRESSIOLOG_TRACE    - never used
PRESSIOLOG_DEBUG    - used
PRESSIOLOG_INFO     - used once in diagnostics.hpp
PRESSIOLOG_WARN     - used in nonlinear solvers, but probably should use PRESSIOLOG_ERROR
PRESSIOLOG_ERROR    - never used
PRESSIOLOG_CRITICAL - used in nonlinear solvers and possibly wrongly used
                      in ode_advance_to_target_time.hpp

Proposed levels

We really only need three configurable levels (naming tbd):

2 - PRESSIOLOG_DEBUG   | full library output
1 - PRESSIOLOG_INFO    | stripped-down library output
0 - PRESSIOLOG_NUMERIC | essential info from solvers, e.g.
    / PRESSIOLOG_BASIC

In addition to these, we need the warning/error levels:

PRESSIOLOG_WARNING     | non-fatal warnings
PRESSIOLOG_ERROR       | fatal errors

As a note, throughout this process we should clean up the use of
the logger. So not just changing the backend, but actually going
through the source and making sure that the logger is used
correctly every time.

Work Plan

  • Create our own logger, with no dependencies besides fmt
  • Keep everything header only
  • Begin in Pressio/pressio (this will likely be one file)
  • Once implemented successfully, consider expanding out to Pressio/pressio-log (that seems superfluous for now)

Implementation

@fnrizzi
Copy link
Member

fnrizzi commented Jan 21, 2025

we need to make sure the logger can handle the case with MPI and without MPI.
I think we should not assume that we have comm world for this, but maybe we can add something to the logger such that is takes the communicator to use and so it prints everything from the rank of that comm.
baiscally allowing one to decide which rank and comm to use to do all prints

another option is to print from all ranks, but i think this becomes a huge pain and not really worth it

Any ideas on how to do this? can you please think of a possible solution for all this and how to go about it?

@fnrizzi
Copy link
Member

fnrizzi commented Jan 21, 2025

one other thing we would need: inside the solvers, i would liek to add option of outputing the solvers info to a file directly.
this might not be related to this logger but i like to have that info formatted too so maybe there is synergy here

@cwschilly
Copy link
Collaborator Author

cwschilly commented Jan 21, 2025

@fnrizzi Here are some thoughts on how to add the option to specify the comm and rank:

Option 1: macros

- This would use the same approach we currently use: PRESSIOLOG_<LEVEL>("message");
- To specify the communicator and rank, we would add overloads:
	PRESSIOLOG_<LEVEL>("message", comm, rank);

- Con: You have to specify comm and rank every time
- Pro: Matches existing implementation

Option 2: class instantiation

- Instantatiate the logger with the logging level (from CMake configuration), as well as comm and rank:

	logger = PRESSIO_LOGGER(level, comm, rank);

- Then just call the logger with the correct level:

	logger.info("message");   // only outputs if logging level is >= "info"
	logger.debug("message");  // only outputs if logging level is >= "'debug"
	logger.error("message");

- Con: Complete change from current implementation,
       have to instantiate logger in every file or pass as argument to functions
- Pro: Reduce duplication (only specify comm/rank once),
       and possibly more intuitive

I think the class (option 2) might be the best approach for long-term maintenance and ability to add new features. It would require a lot of changes to Pressio/pressio source though

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

No branches or pull requests

2 participants