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

[feat] Allow users define custom log handlers and attach them to the framework #3274

Merged
merged 9 commits into from
Oct 18, 2024

Conversation

dmargala
Copy link
Contributor

@dmargala dmargala commented Oct 1, 2024

This PR adds support for defining a custom log handler that can be specified in the reframe configuration file.

For example, adding a plugin log handler would look something like the following:

class PlugInLogHandler(logging.Handler):
    def emit(self, record):
        custom_logger.log(record)

def _create_plugin_handler(site_config, handlers_group):
    return PlugInLogHandler()

from reframe.core.logging import register_plugin_handler
register_plugin_handler(_create_plugin_handler)

There is some prior art in the reframe code base for a similar capability for custom launchers (see extending-the-framework section of the docs). There may be some other ways to implement this by extending the existing Stream or File log handlers to accept custom stream or file objects.

closes #3270

@pep8speaks
Copy link

pep8speaks commented Oct 1, 2024

Hello @dmargala, Thank you for updating!

Cheers! There are no PEP8 issues in this Pull Request!Do see the ReFrame Coding Style Guide

Comment last updated at 2024-10-18 08:09:27 UTC

Copy link
Contributor

@vkarak vkarak left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I have some suggestions on how to make this idea more in sync with the similar idea of custom launchers and schedulers.

We should also add a small documentation section about it in the "how to".

reframe/core/logging.py Outdated Show resolved Hide resolved
reframe/schemas/config.json Outdated Show resolved Hide resolved
reframe/core/logging.py Outdated Show resolved Hide resolved
Copy link
Contributor

@vkarak vkarak left a comment

Choose a reason for hiding this comment

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

Lgtm, just some style nitpicking.

docs/howto.rst Show resolved Hide resolved
docs/howto.rst Outdated Show resolved Hide resolved
docs/howto.rst Outdated Show resolved Hide resolved
reframe/core/logging.py Show resolved Hide resolved
@dmargala
Copy link
Contributor Author

Thanks. I applied suggestions and also fixed indent spacing in the examples (the spacing in the code blocks had inherited the 3-space indents, I changed it to 4-spaces.

Copy link
Contributor

@vkarak vkarak left a comment

Choose a reason for hiding this comment

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

Thanks!

@vkarak vkarak changed the title [feat] Add support for plugin log handler [feat] Allow users define custom log handlers and attach them to the framework Oct 18, 2024
@vkarak vkarak merged commit a00fa32 into reframe-hpc:develop Oct 18, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add support for a plugin log handler
3 participants