47 lines
867 B
C
47 lines
867 B
C
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
void error(char *fmt, ...) {
|
|
va_list args;
|
|
va_start(args, fmt);
|
|
|
|
time_t now = time(NULL);
|
|
struct tm tm = *localtime(&now);
|
|
|
|
fprintf(stderr,
|
|
"[%02d/%02d/%d %02d:%02d:%02d] -ERROR- ",
|
|
tm.tm_mday,
|
|
tm.tm_mon + 1,
|
|
tm.tm_year + 1900,
|
|
tm.tm_hour,
|
|
tm.tm_hour,
|
|
tm.tm_sec);
|
|
vfprintf(stderr, fmt, args);
|
|
fprintf(stderr, "\n");
|
|
|
|
va_end(args);
|
|
}
|
|
|
|
void info(char *fmt, ...) {
|
|
va_list args;
|
|
va_start(args, fmt);
|
|
|
|
time_t now = time(NULL);
|
|
struct tm tm = *localtime(&now);
|
|
|
|
fprintf(stdout,
|
|
"[%02d/%02d/%d %02d:%02d:%02d] -INFO- ",
|
|
tm.tm_mday,
|
|
tm.tm_mon + 1,
|
|
tm.tm_year + 1900,
|
|
tm.tm_hour,
|
|
tm.tm_hour,
|
|
tm.tm_sec);
|
|
vfprintf(stdout, fmt, args);
|
|
fprintf(stdout, "\n");
|
|
|
|
va_end(args);
|
|
}
|