aboutsummaryrefslogtreecommitdiffstats
path: root/src/logging.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-01-15 16:49:06 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-02-29 14:30:14 +0100
commit79599acd663f7c488560d72d63f4e29587fc63a2 (patch)
tree1f1e99928a86f18a0b073da7fb83197c154e97ad /src/logging.c
parente0dc6a1c7cd49433bdf592624ff484576a7ce4e4 (diff)
logging: Move the filter check up as well
There doesn't seem to be a reason not to check the filter. Update and extend the test. Currently the filter function will be called once for the log check and once for the output of it.
Diffstat (limited to 'src/logging.c')
-rw-r--r--src/logging.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/logging.c b/src/logging.c
index 7db7101e..1c9c6634 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -339,6 +339,15 @@ static inline int check_log_to_target(struct log_target *tar, int subsys, int le
level < category->loglevel)
return 0;
+ /* Apply filters here... if that becomes messy we will
+ * need to put filters in a list and each filter will
+ * say stop, continue, output */
+ if ((tar->filter_map & LOG_FILTER_ALL) != 0)
+ return 1;
+
+ if (osmo_log_info->filter_fn)
+ return osmo_log_info->filter_fn(&log_context, tar);
+
/* TODO: Check the filter/selector too? */
return 1;
}
@@ -358,17 +367,6 @@ void osmo_vlogp(int subsys, int level, const char *file, int line,
if (!check_log_to_target(tar, subsys, level))
continue;
- /* Apply filters here... if that becomes messy we will
- * need to put filters in a list and each filter will
- * say stop, continue, output */
- if ((tar->filter_map & LOG_FILTER_ALL) != 0)
- output = 1;
- else if (osmo_log_info->filter_fn)
- output = osmo_log_info->filter_fn(&log_context,
- tar);
- if (!output)
- continue;
-
/* According to the manpage, vsnprintf leaves the value of ap
* in undefined state. Since _output uses vsnprintf and it may
* be called several times, we have to pass a copy of ap. */