Cthulhu  0.2.10
Cthulhu compiler collection
log.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 
3 #include "base/log.h"
4 #include "core/macros.h"
5 
6 static void default_verbose(const char *fmt, va_list args)
7 {
8  CT_UNUSED(fmt);
9  CT_UNUSED(args);
10 }
11 
12 verbose_t gVerboseCallback = default_verbose;
13 static bool gVerboseEnabled = false;
14 
15 void ctu_log_update(bool enable)
16 {
17  gVerboseEnabled = enable;
18 }
19 
20 bool ctu_log_enabled(void)
21 {
22  return gVerboseEnabled;
23 }
24 
26 void ctu_log(const char *fmt, ...)
27 {
28  va_list args;
29  va_start(args, fmt);
30 
31  ctu_vlog(fmt, args);
32 
33  va_end(args);
34 }
35 
37 void ctu_vlog(const char *fmt, va_list args)
38 {
39  if (gVerboseEnabled)
40  {
41  gVerboseCallback(fmt, args);
42  }
43 }
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
verbose_t gVerboseCallback
the global verbose logging callback
Definition: log.c:12
STA_DECL void ctu_vlog(const char *fmt, va_list args)
log a message
Definition: log.c:37
void ctu_log_update(bool enable)
update the verbosity of the logging system
Definition: log.c:15
bool ctu_log_enabled(void)
check if verbose logging is enabled
Definition: log.c:20
void(* verbose_t)(const char *fmt, va_list args)
a logging callback
Definition: log.h:21
#define CT_UNUSED(x)
mark a variable as unused
Definition: macros.h:46
CT_NODISCARD STA_FORMAT_STRING const char * fmt
Definition: str.h:68
STA_DECL void ctu_log(const char *fmt,...)
Definition: log.c:26