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

[ESI][Runtime] Logging API #7569

Merged
merged 2 commits into from
Sep 3, 2024
Merged

[ESI][Runtime] Logging API #7569

merged 2 commits into from
Sep 3, 2024

Conversation

teqdruid
Copy link
Contributor

@teqdruid teqdruid commented Sep 3, 2024

The ESI logging API is intended to be agnostic of the application's logging framework. In other words, it can be adapted to the application's logging method with ease -- users must only extend one class. It also comes with a simple text logger.

It is also designed to enable debug logging in Release builds with (very) minimal performance overhead if the user does not set the log level to debug.

This PR introduces the API, but doesn't use it much. More plumbing will be required to actually use it. In the interest of keeping this PR small, this is left for future work.

@teqdruid teqdruid added the ESI label Sep 3, 2024
@teqdruid teqdruid marked this pull request as ready for review September 3, 2024 03:56
@teqdruid
Copy link
Contributor Author

teqdruid commented Sep 3, 2024

The CI gate clang-format disagrees with clang-format-17...

The ESI logging API is intended to be agnostic of the application's
logging framework. In other words, it can be adapted to the
application's logging method with ease -- users must only extend one
class. It also comes with a simple text logger.

It is also designed to enable debug logging in Release builds with
(very) minimal performance overhead if the user does not set the log
level to debug.

This PR introduces the API, but doesn't use it much. More plumbing will
be required to actually use it. In the interest of keeping this PR
small, this is left for future work.

using namespace esi;

// Necessary in some versions of the c++ standard library to avoid warnings
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mortbopet I think this is true, but I find it quite unusual... am I doing something wrong?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the first time i've seen this pattern, so 🤷.

Copy link
Contributor

@mortbopet mortbopet left a comment

Choose a reason for hiding this comment

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

I generally like the structure. However, I think it would be a nice-to-have (and possibly need-to-have) if we can register multiple loggers (somewhat as what one can do in spdlog). This PR wouldn't change that much, you'd just have to:

  1. iterate through all registered loggers in the log(...) function
  2. Not create the null logger by default

This is super useful in situations where a runtime wants to be in control of it's own (internal) logging implementation, but also need to expose a logging interface externally, to users of the runtime.


using namespace esi;

// Necessary in some versions of the c++ standard library to avoid warnings
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the first time i've seen this pattern, so 🤷.

lib/Dialect/ESI/runtime/cpp/include/esi/Logging.h Outdated Show resolved Hide resolved
@teqdruid
Copy link
Contributor Author

teqdruid commented Sep 3, 2024

I generally like the structure. However, I think it would be a nice-to-have (and possibly need-to-have) if we can register multiple loggers (somewhat as what one can do in spdlog).

This would introduce some performance issues, which I'm ultra concerned about given that I want debug level logging to have the capability to log individual messages. Checking the debugEnable flag in an inline method is relatively cheap. Iterating through loggers isn't. So I think either way, I'd implement it as a "ListLogger" which iterates through subloggers. So can be future work.

@teqdruid teqdruid merged commit 063f744 into main Sep 3, 2024
4 checks passed
@teqdruid teqdruid deleted the teqdruid/esirt/logging branch September 3, 2024 20:53
@teqdruid
Copy link
Contributor Author

teqdruid commented Sep 3, 2024

Merged (& will rely on post-merge comments) so I can cut releases for both PyCDE and ESIRuntime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants