Comment servir des pintes de Guinness "over Internet" ;) Reprise/Fork d'un très ancien code d'un pilier de f.m.b.l : http://tnemeth.free.fr/projets/guinness-server.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

54 lines
1.0 KiB

/*
* printlog
* architecture clients/serveur guinness
* Thomas Nemeth / Arnaud Giersch -- le 23 aout 2001
*
*/
#include <stdio.h>
#include <time.h>
#ifdef SunOS
#include <sys/varargs.h>
#else
#include <stdarg.h>
#endif
#include <string.h>
#include "defines.h"
#include "printlog.h"
extern FILE *outerr;
extern FILE *logfile;
void printlog (log_level loglevel, const char *format, ...) {
va_list ap;
FILE *stream = logfile;
time_t now;
struct tm *today;
char date_time[MAXSTRLEN];
va_start (ap, format);
switch (loglevel) {
case LOG_NOTIFY:
stream = logfile;
break;
case LOG_ERROR:
stream = outerr;
break;
default:
stream = outerr;
break;
}
time (&now);
today = localtime (&now);
memset (date_time, 0, MAXSTRLEN);
strftime (date_time, MAXSTRLEN - 1, "%a %d %b %Y %T", today);
fprintf (stream, "guinnessd: %s - ", date_time);
vfprintf (stream, format, ap);
va_end (ap);
}