/* * Log related functions/defines. * * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #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_LEVEL 0 #define LOG_WARNING_LEVEL 1 #define LOG_DEBUG1_LEVEL 2 #define LOG_DEBUG2_LEVEL 3 /* Call log_message() and print current file and line number. */ #define LOG \ log_message /* perror() replacement with debug level support. */ #define LOG_PERROR(level, message) \ log_message(level, "%s: %s", message, strerror(errno)) void log_message(int level, const char *file, int line, const char *format, ...); #endif