blob: 3d2e009aa2a64c3632845b106a1ab5addbc432ba (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "clog.h"
#define TIMESTRLEN 20
int vlprintf(const char *format, va_list ap)
{
time_t timer = time(NULL);
struct tm *tm_info = localtime(&timer);
char buf[TIMESTRLEN];
strftime(buf, TIMESTRLEN, "%Y/%m/%d %H:%M:%S", tm_info);
free(tm_info);
int n = printf("%s ", buf);
size_t fmtlen = strlen(format) + 2;
char fmt[fmtlen];
memset(fmt, '\0', fmtlen);
strcpy(fmt, format);
strcat(fmt, "\n");
n += vprintf(format, ap);
return n;
}
|