diff options
Diffstat (limited to 'common/tools.cpp')
-rw-r--r-- | common/tools.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/common/tools.cpp b/common/tools.cpp index 1e40ccc..797dbfe 100644 --- a/common/tools.cpp +++ b/common/tools.cpp @@ -17,6 +17,26 @@ using namespace std; +#ifdef DEBUG + +#define MESSAGE_SIZE 256 +namespace upnp { + void log_debug_msg(const char* file, const char* func, int line, int level, const char* msg, ...){ + char* lvlenv = getenv("UPNP_DEBUG_LEVEL"); + int debug_level = lvlenv ? atoi(lvlenv) : 0; + if(level && debug_level >= level){ + va_list ap; + char message[MESSAGE_SIZE]; + + snprintf(message, sizeof(message), "[%s:%d] %s - %s", file, line, func, msg); + va_start(ap, msg); + vsyslog(LOG_NOTICE, message, ap); + va_end(ap); + } + } +} +#endif + namespace upnp { namespace tools { |