-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.c
More file actions
41 lines (32 loc) · 785 Bytes
/
Copy pathtest.c
File metadata and controls
41 lines (32 loc) · 785 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
#include <time.h>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#define LOGTEE_UNIQUE_STATE
#include "logtee.h"
const char *cback() {
static char buf[128];
snprintf(buf, sizeof buf, "[%zu]: ", time(NULL));
return buf;
}
int main() {
LOG_teefile(stderr, 0);
LOG_prefixcallback(cback);
LOGI("%s, %s!\n", "Hello", "World");
LOGE("Nooo!\n");
LOGW("Hmm...\n");
LOG_teefile(stderr, 1);
LOG_teefile(stderr, 2);
LOGI("Info 2\n"); // 1 copy of this
LOGW("Warn 2\n"); // 2 copies of this
LOGE("Err 2\n"); // 3 copies of t his
LOG_reset();
LOGI("What?\n"); // 0 copies of this
LOG_teefile(stderr, 0);
LOG_teepath("log.txt", 0);
unlink("/");
PLOGE("unlink"); // perror()-like
LOGI("Info 3\n");
LOGF("Fatal\n");
LOGI("Not reached\n"); // not reached
}