static HANDLE loghandle = NULL;
#endif
static const char *logident = NULL;
-bool logcontrol = false;
+bool logcontrol = false; // controlled by REQ_LOG <level>
int umbilical = 0;
+static bool should_log(int level) {
+ return (level <= debug_level && logmode != LOGMODE_NULL) || logcontrol;
+}
+
static void real_logger(int level, int priority, const char *message) {
char timestr[32] = "";
static bool suppress = false;
- // Bail out early if there is nothing to do.
if(suppress) {
return;
}
- if(!logcontrol && (level > debug_level || logmode == LOGMODE_NULL)) {
- return;
- }
-
if(level <= debug_level) {
switch(logmode) {
case LOGMODE_STDERR:
va_list ap;
char message[1024] = "";
+ if(!should_log(level)) {
+ return;
+ }
+
va_start(ap, format);
int len = vsnprintf(message, sizeof(message), format, ap);
message[sizeof(message) - 1] = 0;
char message[1024];
size_t msglen = sizeof(message);
+ if(!should_log(DEBUG_ALWAYS)) {
+ return;
+ }
+
int len = vsnprintf(message, msglen, format, ap);
message[sizeof(message) - 1] = 0;