89 |
/* ------------------------------------------------------------- Definitions */ |
/* ------------------------------------------------------------- Definitions */ |
90 |
|
|
91 |
|
|
|
#define MESSAGE_SIZE 1024 |
|
92 |
static FILE *LOG= NULL; |
static FILE *LOG= NULL; |
93 |
static char time_str[STRLEN]; |
static char time_str[STRLEN]; |
94 |
|
|
133 |
/** |
/** |
134 |
* Log a message to monits logfile or syslog. If a TTY exist the log |
* Log a message to monits logfile or syslog. If a TTY exist the log |
135 |
* message is also sent to stderr. |
* message is also sent to stderr. |
136 |
* @param format A formated (printf-style) string to log |
* @param s A formated (printf-style) string to log |
137 |
*/ |
*/ |
138 |
void log_log(const char *format, ...) { |
void log_log(const char *s, ...) { |
139 |
|
|
140 |
|
long len; |
141 |
va_list ap; |
va_list ap; |
142 |
char msg[MESSAGE_SIZE]; |
char *msg= NULL; |
143 |
|
|
144 |
ASSERT(format); |
ASSERT(s); |
145 |
|
|
146 |
va_start(ap,format); |
va_start(ap,s); |
147 |
vsnprintf(msg, MESSAGE_SIZE, format, ap); |
msg= format(s, ap, &len); |
148 |
va_end(ap); |
va_end(ap); |
149 |
|
|
150 |
if(! Run.dolog) goto nolog; |
if(! Run.dolog) goto nolog; |
166 |
fflush(stderr); |
fflush(stderr); |
167 |
|
|
168 |
} |
} |
169 |
|
|
170 |
|
FREE(msg); |
171 |
|
|
172 |
} |
} |
173 |
|
|