File: [Platon] / tucniak / util / log.c (download)
Revision 1.1.1.1 (vendor branch), Fri Nov 11 16:08:27 2005 UTC (18 years, 4 months ago) by koli
Changes since 1.1: +0 -0
lines
Initial import
|
// Copyright (c) 2003 Juraj Kolesár (koli) <koli@koli.sk>
#include <curses.h>
#include <time.h>
#include "log.h"
FILE *log_file;
void log_init() {
log_file = fopen("tucniak.log", "a");
}
void log(const char *fmt, ...) {
va_list args;
time_t ct;
char *tmstr;
char buffer[1024];
va_start(args, fmt);vsnprintf(buffer, 1023, fmt, args);va_end(args);
ct = time(0);
tmstr = asctime(localtime(&ct));
*(tmstr + strlen(tmstr) - 1) = '\0';
fprintf(log_file, "%-15.15s :: %s\n", tmstr + 4, buffer);
fflush(log_file);
}
void log_close() {
fclose(log_file);
}
Platon Group <platon@platon.org> http://platon.org/
|