Skip to content

Commit 025bbc7

Browse files
committed
Don't filter log message with level ERROR and above
The logging filters were being applied to all log messages regardless of level. However, message with ERROR level and above should never be filtered. In addition, the general exception handler used by the emulator can also be used by the main function, so remove the duplicate exception handling.
1 parent 88ea9f9 commit 025bbc7

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/lib/logging/logging.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ int vortex_logger_log(vortex_logger_t *logger, log_level_t level,
395395
log_stream_t *next;
396396
char string[2048];
397397
size_t s = 0;
398-
bool do_log;
398+
bool do_log = true;
399399

400400
if (!log_setup || !logger)
401401
return EFAULT;
@@ -407,12 +407,18 @@ int vortex_logger_log(vortex_logger_t *logger, log_level_t level,
407407
return 0;
408408

409409
/*
410-
* Filtering is done with the lock held to protect against
411-
* a filter being added while logging is in progress.
410+
* Message with levels ERROR and higher (more severe) are
411+
* not filtered.
412412
*/
413-
pthread_mutex_lock(&log_setup->lock);
414-
do_log = filter_record(logger);
415-
pthread_mutex_unlock(&log_setup->lock);
413+
if (level < LOG_LEVEL_ERROR) {
414+
/*
415+
* Filtering is done with the lock held to protect against
416+
* a filter being added while logging is in progress.
417+
*/
418+
pthread_mutex_lock(&log_setup->lock);
419+
do_log = filter_record(logger);
420+
pthread_mutex_unlock(&log_setup->lock);
421+
}
416422

417423
if (!do_log)
418424
return 0;

vortex_run.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ def emulator_exception_handler(exc_class, exc, tb):
101101
frame = _tb.tb_frame
102102
co = frame.f_code
103103
logging.critical(f"Exception occured at {co.co_name}:{frame.f_lineno} [{co.co_filename}]:")
104-
logging.critical(f" {str(exc)}")
104+
logging.critical(f" Exception: {str(exc)}")
105105
if logging.get_level() <= logging.DEBUG:
106106
lines = traceback.format_tb(tb)
107-
for line in lines:
108-
logging.critical(" " + line)
107+
for entry in lines:
108+
for line in entry.split("\n"):
109+
logging.critical(" " + line.rstrip())
109110

110111
def emulator_thread_exception_handler(args):
111112
emulator_exception_handler(args.exc_type, args.exc_value, args.exc_traceback)
@@ -150,12 +151,6 @@ def main():
150151
emulation.start()
151152
except KeyboardInterrupt:
152153
pass
153-
except Exception as e:
154-
logging.critical(f"Emulator exception: {e}")
155-
if opts.debug.lower() == "debug":
156-
lines = traceback.format_exception(e)
157-
for line in lines:
158-
logging.critical(line)
159154
finally:
160155
emulation.stop()
161156

0 commit comments

Comments
 (0)