Use a wrapper for logging

This commit is contained in:
Igor Socec 2016-11-28 02:01:39 +01:00
parent 8725d1c1f1
commit 7973b5a5e8
7 changed files with 91 additions and 99 deletions

View file

@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
@ -12,12 +13,25 @@
/* ========================================================================== */
#define APPNAME "moxerver"
#define BUFFER_LEN 128 /* length of a data buffer */
/* ========================================================================== */
int debug_messages; /* if > 0 debug messages will be printed */
/**
* Wrapper for printing a log message to stderr.
* Uses a "printf" syntax with format and arguments. The newline character '\n'
* is appended to the message.
*/
#define LOG(...) \
do { \
fprintf(stderr, "[%s][%s] ", APPNAME, __func__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} while(0)
/* ========================================================================== */
#define TIMESTAMP_FORMAT "%Y-%m-%dT%H:%M:%S" /* follow ISO 8601 format */