Skip to content

Commit 47a98a0

Browse files
authored
Merge branch 'master' into master
2 parents 490dc8b + ccf8c36 commit 47a98a0

4 files changed

Lines changed: 54 additions & 4 deletions

File tree

src/rule.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,12 +635,10 @@ zlog_rule_t *zlog_rule_new(char *line,
635635
goto err;
636636
}
637637

638-
639638
/* check and set category */
640639
for (p = category; *p != '\0'; p++) {
641-
if ((!isalnum(*p)) && (*p != '_') && (*p != '*') && (*p != '!')) {
642-
zc_error("category name[%s] character is not in [a-Z][0-9][_!*]",
643-
category);
640+
if ((!isalnum(*p)) && (*p != '_') && (*p != '-') && (*p != '*') && (*p != '!')) {
641+
zc_error("category name[%s] character is not in [a-Z][0-9][_!*-]", category);
644642
goto err;
645643
}
646644
}

test/makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ exe = \
2222
test_syslog \
2323
test_default \
2424
test_profile \
25+
test_default \
26+
test_profile \
27+
test_category \
2528
test_enabled
2629

2730
all : $(exe)

test/test_category.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* This file is part of the zlog Library.
3+
*
4+
* Copyright (C) 2011 by Hardy Simpson <HardySimpson1984@gmail.com>
5+
*
6+
* Licensed under the LGPL v2.1, see the file COPYING in base directory.
7+
*/
8+
9+
#include <stdio.h>
10+
#include "zlog.h"
11+
12+
int main(int argc, char** argv)
13+
{
14+
int rc;
15+
zlog_category_t *zc;
16+
17+
rc = zlog_init("./test_category.conf");
18+
if (rc) {
19+
printf("init failed\n");
20+
return -1;
21+
}
22+
23+
zc = zlog_get_category("my_cat");
24+
if (!zc) {
25+
printf("get cat fail\n");
26+
zlog_fini();
27+
return -2;
28+
}
29+
30+
zlog_debug(zc, "hello, zlog - debug");
31+
32+
zc = zlog_get_category("my-cat");
33+
if (!zc) {
34+
printf("get cat fail\n");
35+
zlog_fini();
36+
return -2;
37+
}
38+
39+
zlog_info(zc, "hello, zlog - info");
40+
41+
zlog_fini();
42+
43+
return 0;
44+
}

test/test_category.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[global]
2+
default format = "%V %v %m%n"
3+
[rules]
4+
my_cat.* >stdout;
5+
my-cat.* >stdout;

0 commit comments

Comments
 (0)