You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/howto.rst
+60Lines changed: 60 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1162,3 +1162,63 @@ If you use a Python-based configuration file, you can define your custom launche
1162
1162
.. note::
1163
1163
1164
1164
In versions prior to 4.0, launchers could only be implemented inside the source code tree of ReFrame.
1165
+
1166
+
1167
+
.. _custom-loggers:
1168
+
1169
+
Implementing a custom log handler
1170
+
---------------------------------
1171
+
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.
1176
+
1177
+
Define a custom log handler class based on :class:`~logging.Handler` which uses a custom logging API:
1178
+
1179
+
.. code-block:: python
1180
+
1181
+
import logging
1182
+
import mylogger
1183
+
1184
+
classMyLoggerHandler(logging.Handler):
1185
+
def__init__(self, key):
1186
+
super().__init__()
1187
+
self.key = key
1188
+
1189
+
defemit(self, record):
1190
+
myrecord = {
1191
+
'value': record.check_perf_value,
1192
+
}
1193
+
mylogger.log(self.key, myrecord)
1194
+
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:
1196
+
1197
+
.. code-block:: python
1198
+
1199
+
from reframe.core.logging import register_log_handler
0 commit comments