X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Flog.h;h=16f45ea09071b7746586e26e787aabce321d3abc;hb=HEAD;hp=e129e9f29fc8a424e946870bcc00967c839371d8;hpb=8db64b0eebeaa80e46b2df40b91af741e533e7bc;p=tlsproxy%2Ftlsproxy.git diff --git a/src/log.h b/src/log.h index e129e9f..16f45ea 100644 --- a/src/log.h +++ b/src/log.h @@ -1,7 +1,7 @@ /* * Log related functions/defines. * - * Copyright (C) 2011 Simon Ruderich + * Copyright (C) 2011-2014 Simon Ruderich * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,28 +20,26 @@ #ifndef LOG_H #define LOG_H +/* Log constants to be used with LOG() and LOG_PERROR() macros. */ +#define ERROR LOG_ERROR_LEVEL, __FILE__, __LINE__ +#define WARNING LOG_WARNING_LEVEL, __FILE__, __LINE__ +#define DEBUG1 LOG_DEBUG1_LEVEL, __FILE__, __LINE__ +#define DEBUG2 LOG_DEBUG2_LEVEL, __FILE__, __LINE__ + /* Log level constants. */ -#define LOG_ERROR 0 -#define LOG_WARNING 1 -#define LOG_DEBUG 2 +#define LOG_ERROR_LEVEL 0 +#define LOG_WARNING_LEVEL 1 +#define LOG_DEBUG1_LEVEL 2 +#define LOG_DEBUG2_LEVEL 3 -/* Helper macro for LOG/LOG_PERROR. Print file/line number if compiled with - * debug output. */ -#ifdef DEBUG -#define LOG_PRINT_LOCATION fprintf(stdout, "%s:%-3d ", __FILE__, __LINE__); -#else -#define LOG_PRINT_LOCATION -#endif /* Call log_message() and print current file and line number. */ #define LOG \ - LOG_PRINT_LOCATION \ log_message /* perror() replacement with debug level support. */ #define LOG_PERROR(level, message) \ - LOG_PRINT_LOCATION \ log_message(level, "%s: %s", message, strerror(errno)) -void log_message(int level, const char *format, ...); +void log_message(int level, const char *file, int line, const char *format, ...); #endif