1 /* This file is part of pr-downloader (GPL v2 or later), see the LICENSE file */ 2 3 #ifndef LOGGER_H 4 #define LOGGER_H 5 6 #include <stdio.h> 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 void LOG_DISABLE(bool disableLogging); 13 14 enum L_LEVEL { 15 L_ERROR = 1, 16 L_RAW = 2, 17 L_INFO = 3, 18 L_DEBUG = 4 19 }; 20 21 /** 22 * plain log output 23 */ 24 void L_LOG(L_LEVEL level, const char* format, ...); 25 26 #define LOG(...) \ 27 L_LOG(L_RAW, __VA_ARGS__) 28 29 #define LOG_ERROR(fmt, ...) \ 30 L_LOG(L_ERROR, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) 31 32 #define LOG_INFO(...) \ 33 L_LOG(L_INFO, __VA_ARGS__) 34 35 #ifndef NDEBUG 36 #define LOG_DEBUG(fmt, ...) \ 37 L_LOG(L_DEBUG, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); 38 #else 39 #define LOG_DEBUG(fmt, ...) 40 #endif 41 42 void LOG_DOWNLOAD(const char* filename); 43 44 /** 45 * output progress bar 46 * @param done bytes already downloaded 47 * @param total total bytes to download 48 * @param forceOutput force output 49 */ 50 void LOG_PROGRESS(long done, long total, bool forceOutput=false); 51 52 #ifdef __cplusplus 53 } 54 #endif 55 56 57 #endif 58