2 * Sherlock Library -- Logging
4 * (c) 1997--2001 Martin Mares <mj@ucw.cz>
16 static byte *log_progname;
26 vlog(unsigned int cat, const char *msg, va_list args)
28 time_t tim = time(NULL);
29 struct tm *tm = localtime(&tim);
34 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm);
35 fprintf(stderr, "%c %s ", cat, buf);
37 fprintf(stderr, "[%s (%d)] ", log_progname, log_pid);
38 vfprintf(stderr, msg, args);
44 log(unsigned int cat, const char *msg, ...)
59 vlog(L_FATAL, msg, args);
79 log_progname = basename(argv0);
87 int fd = open(name, O_WRONLY | O_CREAT | O_APPEND, 0666);
89 die("Unable to open log file %s: %m", name);