Skip to content

Commit

Permalink
improves debug
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Jan 21, 2024
1 parent a04e1c9 commit 74d392e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cppmyth/src/private/debug.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2015 Jean-Luc Barriere
* Copyright (C) 2014-2024 Jean-Luc Barriere
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
Expand Down Expand Up @@ -38,7 +38,7 @@ typedef struct
void (*msg_callback)(int level, char* msg);
} debug_ctx_t;

static debug_ctx_t debug_ctx = {LIBTAG, DBG_NONE, NULL};
static debug_ctx_t debug_ctx = {LIBTAG, DBG_NONE, nullptr};

/**
* Set the debug level to be used for the subsystem
Expand All @@ -48,7 +48,7 @@ static debug_ctx_t debug_ctx = {LIBTAG, DBG_NONE, NULL};
*/
static inline void __dbg_setlevel(debug_ctx_t* ctx, int level)
{
if (ctx != NULL)
if (ctx != nullptr)
{
ctx->cur_level = level;
}
Expand All @@ -62,7 +62,7 @@ static inline void __dbg_setlevel(debug_ctx_t* ctx, int level)
*/
static inline void __dbg(debug_ctx_t* ctx, int level, const char* fmt, va_list ap)
{
if (ctx != NULL && level <= ctx->cur_level)
if (ctx != nullptr)
{
char msg[4096];
int len = snprintf(msg, sizeof (msg), "(%s)", ctx->name);
Expand Down Expand Up @@ -95,8 +95,9 @@ void NSROOT::DBGNone()

void NSROOT::DBG(int level, const char* fmt, ...)
{
if (level > debug_ctx.cur_level)
return;
va_list ap;

va_start(ap, fmt);
__dbg(&debug_ctx, level, fmt, ap);
va_end(ap);
Expand Down

0 comments on commit 74d392e

Please sign in to comment.