Skip to content

Commit 8d6e000

Browse files
committed
update doc suggestions
1 parent 6c52643 commit 8d6e000

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

docs/howto.rst

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,10 @@ If you use a Python-based configuration file, you can define your custom launche
11691169
Implementing a custom log handler
11701170
---------------------------------
11711171

1172-
Here's an example implementation of a custom log handler defined in a Python-based configuration file.
1172+
.. versionadded:: 4.7
1173+
1174+
ReFrame allows you to define custom log handlers and attach them to the framework.
1175+
Here's an example implementation of a custom log handler and how it can be used in a Python-based configuration file.
11731176

11741177
Define a custom log handler class based on :class:`~logging.Handler` which uses a custom logging API:
11751178

@@ -1179,43 +1182,43 @@ Define a custom log handler class based on :class:`~logging.Handler` which uses
11791182
import mylogger
11801183
11811184
class MyLoggerHandler(logging.Handler):
1182-
def __init__(self, key):
1183-
super().__init__()
1184-
self.key = key
1185+
def __init__(self, key):
1186+
super().__init__()
1187+
self.key = key
11851188
1186-
def emit(self, record):
1187-
myrecord = {
1188-
'value': record.check_perf_value,
1189-
}
1190-
mylogger.log(self.key, myrecord)
1189+
def emit(self, record):
1190+
myrecord = {
1191+
'value': record.check_perf_value,
1192+
}
1193+
mylogger.log(self.key, myrecord)
11911194
1192-
Apply the :func:`~reframe.core.logging.register_log_handler` decorator to a function returns an instance of the custom log handler:
1195+
Applying the :func:`@register_log_handler <reframe.core.logging.register_log_handler>` decorator to a function returns an instance of the custom log handler:
11931196

11941197
.. code-block:: python
11951198
11961199
from reframe.core.logging import register_log_handler
11971200
11981201
@register_log_handler("mylogger")
11991202
def _create_mylogger_handler(site_config, config_prefix):
1200-
key = site_config.get(f'{config_prefix}/key')
1201-
return MyLoggerHandler(key)
1203+
key = site_config.get(f'{config_prefix}/key')
1204+
return MyLoggerHandler(key)
12021205
12031206
1204-
Finally, add a handler entry with type matching registered name for the custom log handler to the site config:
1207+
Finally, add a handler entry with type matching the registered name for the custom log handler to the site config:
12051208

12061209
.. code-block:: python
12071210
12081211
site_configuration = {
1209-
'logging': [
1210-
{
1211-
'handlers': [
1212-
{
1213-
'type': 'mylogger',
1214-
'key': 'abc',
1215-
},
1216-
...
1217-
]
1218-
}
1219-
],
1220-
...
1212+
'logging': [
1213+
{
1214+
'handlers': [
1215+
{
1216+
'type': 'mylogger',
1217+
'key': 'abc',
1218+
},
1219+
...
1220+
]
1221+
}
1222+
],
1223+
...
12211224
}

0 commit comments

Comments
 (0)