-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
45 lines (40 loc) · 1.23 KB
/
test.c
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
42
43
44
45
/*
* Copyright (c) 2004-2006 Maxim Sobolev <[email protected]>
* Copyright (c) 2006-2016 Sippy Software, Inc., http://www.sippysoft.com
* All rights reserved.
*
*/
#include <err.h>
#include <siplog.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
int main()
{
siplog_t log, globallog;
int i;
struct timespec interval;
globallog = siplog_open("test", NULL, LF_REOPEN);
siplog_memdeb_setbaseln();
siplog_write(SIPLOG_DBUG, globallog, "staring process...");
log = siplog_open("test", "[email protected]", 0);
if (log == NULL || globallog == NULL)
err(1, "can't open logs");
siplog_write(SIPLOG_DBUG, log, "level DBUG, %d", 1);
siplog_write(SIPLOG_WARN, log, "level WARN, %d", 2);
siplog_write(SIPLOG_ERR, log, "level ERR, %d", 3);
for (i = 0; i < 10000;) {
siplog_write(SIPLOG_DBUG, log, "message #%d", ++i);
/* sleep 0.0000001 second */
interval.tv_sec = 0;
interval.tv_nsec = 100;
nanosleep(&interval, NULL);
}
siplog_write(SIPLOG_DBUG, globallog, "stoping process...");
siplog_close(log);
siplog_memdeb_dumpstats(SIPLOG_DBUG, globallog);
siplog_close(globallog);
/* allow worker thread to finish its job in async mode */
sleep(1);
exit(0);
}