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