-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
log.c
42 lines (39 loc) · 876 Bytes
/
log.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <unistd.h>
#include "log.h"
#include "globals.h"
void my_log(int priority, const char *format, ...)
{
va_list ap;
time_t now;
struct tm timeinfo;
char timestring[32];
va_start(ap, format);
#ifndef MINIMALISTIC_BUILD
if (globals.no_syslog) {
#endif
time(&now);
localtime_r(&now, &timeinfo);
strftime(timestring, sizeof(timestring), "%Y-%m-%d %H:%M:%S", &timeinfo);
fprintf(
stderr, "%s %s[%d]: ",
timestring,
#ifndef MINIMALISTIC_BUILD
globals.daemon_name,
#else
"mysql-honeypotd",
#endif
getpid()
);
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
#ifndef MINIMALISTIC_BUILD
}
else {
vsyslog(priority, format, ap);
}
#endif
va_end(ap);
}