Skip to content

Commit de91232

Browse files
committed
add actual test case files
comment the sleep(1) to speed up the test.
1 parent 71f7e33 commit de91232

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

test/test_prompt.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* This file is part of the zlog Library.
3+
*
4+
* Copyright (C) 2020 by Bjoern Riemer <bjoern.c3@nixda.biz>
5+
*
6+
* Licensed under the LGPL v2.1, see the file COPYING in base directory.
7+
*/
8+
#include <stdio.h>
9+
#include "zlog.h"
10+
#include <unistd.h>
11+
12+
int main(int argc, char** argv)
13+
{
14+
int rc;
15+
zlog_category_t *zc,*pzc;
16+
17+
rc = zlog_init("test_prompt.conf");
18+
if (rc) {
19+
printf("init failed\n");
20+
return -1;
21+
}
22+
23+
zc = zlog_get_category("my_cat");
24+
pzc = zlog_get_category("prompt");
25+
if (!zc || !pzc) {
26+
printf("get cat fail\n");
27+
zlog_fini();
28+
return -2;
29+
}
30+
31+
zlog_debug(zc, "%s%d", "hello, zlog ", 1);
32+
zlog_info(zc, "hello, zlog 2");
33+
34+
for (int i =0; i<15;i++){
35+
zlog_info(pzc, "prompt>");
36+
sleep(1);
37+
if (! (i%3))
38+
zlog_debug(zc, "dummy log entry %d",i);
39+
if (! (i%5))
40+
zlog_info(zc, "hello, zlog %d",i);
41+
}
42+
zlog_info(zc, "done");
43+
44+
// zlog_profile();
45+
46+
zlog_fini();
47+
48+
return 0;
49+
}

test/test_prompt.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[global]
2+
strict init = true
3+
buffer min = 1024
4+
buffer max = 0
5+
6+
[formats]
7+
simple = "%r%d %V %m%n"
8+
prompt = "%r%d(%T)>%m"
9+
10+
[rules ]
11+
!.* >stdout;simple
12+
prompt.* >stdout;prompt

0 commit comments

Comments
 (0)