Skip to content

Commit 1ef9b5b

Browse files
authored
Merge pull request #3520 from vkarak/bugfix/analytics-nologging
[bugfix] Disable file logging when emitting DB records
2 parents 7611a6a + d39490d commit 1ef9b5b

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

reframe/core/logging.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,19 @@ def adjust_verbosity(self, num_steps):
971971

972972
h.setLevel(new_level)
973973

974+
def set_handler_level(self, level, filter=None):
975+
'''Set handler level for handlers attached to this logger.
976+
977+
:arg level: The new level.
978+
:arg filter: A callable accepting a single argument, which is the
979+
handler type as declared in ReFrame's configuration. If the filter
980+
is :obj:`None` then the level applies to all handlers, otherwise
981+
it will apply to all handlers that the filter return :obj:`True`.
982+
'''
983+
for h in self.logger.handlers:
984+
if filter is None or filter(h._rfm_type):
985+
h.setLevel(level)
986+
974987

975988
# A logger that doesn't log anything
976989
null_logger = LoggerAdapter()

reframe/frontend/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,8 @@ def restrict_logging():
10401040
if options.describe_stored_sessions:
10411041
# Restore logging level
10421042
printer.setLevel(logging.INFO)
1043+
printer.set_handler_level(logging.WARNING,
1044+
lambda htype: htype != 'stream')
10431045
with exit_gracefully_on_error('failed to retrieve session data',
10441046
printer):
10451047
printer.info(jsonext.dumps(reporting.session_info(
@@ -1050,6 +1052,8 @@ def restrict_logging():
10501052
if options.describe_stored_testcases:
10511053
# Restore logging level
10521054
printer.setLevel(logging.INFO)
1055+
printer.set_handler_level(logging.WARNING,
1056+
lambda htype: htype != 'stream')
10531057
namepatt = '|'.join(n.replace('%', ' %') for n in options.names)
10541058
with exit_gracefully_on_error('failed to retrieve test case data',
10551059
printer):

reframe/frontend/reporting/storage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ def _db_store_report(self, conn, report, report_file_path):
228228

229229
return session_uuid
230230

231+
@time_function
231232
def store(self, report, report_file=None):
232233
with self._db_lock():
233234
with self._db_connect(self._db_file()) as conn:

0 commit comments

Comments
 (0)