2 * Sherlock Library -- Logging
4 * (c) 1997--2001 Martin Mares <mj@ucw.cz>
16 static char *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);
32 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm);
33 fprintf(stderr, "%c %s ", cat, buf);
37 fprintf(stderr, "[%s (%d)] ", log_progname, log_pid);
39 fprintf(stderr, "[%s] ", log_progname);
44 fprintf(stderr, "[%d] ", log_pid);
46 vfprintf(stderr, msg, args);
52 log(unsigned int cat, const char *msg, ...)
67 vlog(L_FATAL, msg, args);
87 log_progname = basename(argv0);
95 int fd = open(name, O_WRONLY | O_CREAT | O_APPEND, 0666);
97 die("Unable to open log file %s: %m", name);