1 /* 2 * aprsc 3 * 4 * (c) Heikki Hannikainen, OH7LZB <hessu@hes.iki.fi> 5 * 6 * This program is licensed under the BSD license, which can be found 7 * in the file LICENSE. 8 * 9 */ 10 11 #ifndef LOG_H 12 #define LOG_H 13 14 #define LOG_LEN 2048 15 16 #define L_STDERR 1 /* Log to stderror */ 17 #define L_SYSLOG (1 << 1) /* Log to syslog */ 18 #define L_FILE (1 << 2) /* Log to a file */ 19 20 #ifdef __CYGWIN__ 21 #define L_DEFDEST L_FILE 22 #else 23 #define L_DEFDEST L_STDERR 24 #endif 25 26 #define LOG_LEVELS "emerg alert crit err warning notice info debug" 27 #define LOG_DESTS "syslog stderr file" 28 29 #include <syslog.h> 30 31 extern char *log_levelnames[]; 32 extern char *log_destnames[]; 33 34 extern int log_dest; /* Logging destination */ 35 extern int log_level; /* Logging level */ 36 extern char *log_dir; /* Log directory */ 37 38 extern int log_rotate_size; /* Rotate log when it reaches a given size */ 39 extern int log_rotate_num; /* How many logs to keep around */ 40 41 42 extern char *str_append(char *s, const char *fmt, ...); 43 44 extern int pick_loglevel(char *s, char **names); 45 extern int open_log(char *name, int reopen); 46 extern int close_log(int reopen); 47 extern int hlog(int priority, const char *fmt, ...); 48 extern int hlog_packet(int priority, const char *packet, int packetlen, const char *fmt, ...); 49 50 extern int accesslog_open(char *logd, int reopen); 51 extern int accesslog_close(char *reopenpath); 52 extern int accesslog(const char *fmt, ...); 53 54 extern int writepid(char *name); 55 extern int closepid(void); 56 57 #endif 58