11 #define CHECK_MODE(i, c) (((i) & (c)) == (c)) 12 #define APPEND_MODE(v, m, c) if(CHECK_MODE(m, c)) \ 15 #define CASE(s, v) case LOG_##s: \ 16 v = strdup(LOG_##s##_NAME); \ 19 static short _output_lvl, _output_mode;
20 static FILE *_output_file_stream;
28 if(lvl >= LOG_EMERG && lvl <= LOG_DEBUG)
47 _output_file_stream = out;
69 void output1(
int lvl,
const char *msg, ...)
71 if(lvl <= _output_lvl)
78 if(lvl <= LOG_WARNING || lvl == LOG_DEBUG)
81 asprintf(&msg1,
"%s: %s", lvlname, msg);
84 buf_len = vasprintf(&buf, msg1, ap);
87 buf_len = vasprintf(&buf, msg, ap);
92 syslog(LOG_DAEMON | lvl,
"%s", buf);
100 fwrite(buf, buf_len + 1, 1, _output_file_stream);
101 fflush(_output_file_stream);
#define _OUTPUT_MODE_SYSLOG
Print messages to syslog.
#define _OUTPUT_MODE_PRINT
Print messages to stdout.
#define APPEND_MODE(v, m, c)
#define _OUTPUT_MODE_FILE
Print messages to a logfile (also use set_output_file to set the desired logfile).
int set_output_level(int lvl)
char * levelname(int lvl)
int set_output_mode(int mode)
#define _OUTPUT_GET_CURRENT_VALUE
Get the current value (See set_output_level, set_output_mode).
void output1(int lvl, const char *msg,...)
int set_output_file(FILE *out)