From de6dd72dbbbcc7facf25c4a2521c71f653c7b1b2 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 17 Nov 2015 11:52:24 +0100 Subject: log: Add log_check_level function This commit adds this predicate function which can be used to avoid the execution of code if a certain log level is not enabled. The function will only return 0 (false), if it is sure that a logging call for the same facility and level will not produce any output. This safety criterion shall ensure, that no logging output is lost due to the use of this predicate as a guard. On the other hand, even if the predicate returns != 0 (true), no logging output might get generated by a similar logging command. Note that the current implementation is not focussed on performance, which could be improved by using a lookup table instead of iterating through every target. Sponsored-by: On-Waves ehf --- include/osmocom/core/logging.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index 1c159d0b..290b33df 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -198,6 +198,7 @@ void logp2(int subsys, unsigned int level, const char *file, int line, int cont, const char *format, ...) __attribute__ ((format (printf, 6, 7))); int log_init(const struct log_info *inf, void *talloc_ctx); +int log_check_level(int subsys, unsigned int level); /* context management */ void log_reset_context(void); -- cgit v1.2.3