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

Add a Logger class #3076

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open

Add a Logger class #3076

wants to merge 53 commits into from

Conversation

alkino
Copy link
Member

@alkino alkino commented Sep 10, 2024

No description provided.

@alkino alkino changed the base branch from master to cornu/modernize_printf September 10, 2024 14:52
Base automatically changed from cornu/modernize_printf to master September 12, 2024 12:55
@alkino
Copy link
Member Author

alkino commented Sep 16, 2024

@1uc About your general comment, I want to keep this class simple and my future plan is to have more kind of output. error, warning, fatal, ...

How should we handle this debug going to stderr? I want to keep it simple.

Copy link

✔️ be9c98d -> Azure artifacts URL

Copy link

✔️ f8182ca -> Azure artifacts URL

@1uc
Copy link
Collaborator

1uc commented Sep 17, 2024

I think there's two (or three) abstractions:

  1. An interface for writing to files/streams. This interface needs to supports injecting a callback that intercepts stderr and stdout and sends them to whatever matlab or jupyter want.
  2. If the prior can't/wont also do formatting, then the previous becomes a lot more low-level; and there's a need for an API that accepts a formattable string (along with the arguments). It formats and calls the first API.
  3. The second big concept is the Logger. The logger requires the user to pick a severity level (that ideally can be silenced, etc); and takes away their choices using stderr vs stdcout. Since we already have strict requirements about redirecting, I'd say, we don't want the logger to have a callback (even though this is otherwise common), i.e. it uses API from Point 1 (or 2). Something else loggers do is they often modify the message, i.e. by adding severity markers, e.g. ERROR: {}, or filename/linenumber/timestamp information: ERROR: foo.cpp:11 {}.

The current implementation requires us to use the logger to write to std::cout. This includes things like pretty printing datastructures or other things that are not logging, but just regular program output. This type of output we also want to intercept and redirect. To do this we need Abstraction 1; otherwise we either have multiple implementations of the callback; or abuse the logger.

src/ivoc/ivoc.cpp Outdated Show resolved Hide resolved
src/utils/logger.hpp Show resolved Hide resolved
Copy link

✔️ 434ade7 -> Azure artifacts URL

Copy link

✔️ bfe9e18 -> Azure artifacts URL

Copy link

✔️ 3163fdb -> Azure artifacts URL

src/utils/logger.hpp Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Sep 18, 2024

Copy link

✔️ e4b2f91 -> Azure artifacts URL

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.

5 participants