Commit b9abb21a authored by Hardy Simpson's avatar Hardy Simpson

feature: support # comment in same line with conf

parent cc47d897
......@@ -238,6 +238,7 @@ static int zlog_conf_build_with_file(zlog_conf_t * a_conf)
char *p = NULL;
int line_no = 0;
int i = 0;
int in_quotation = 0;
int section = 0;
/* [global:1] [levels:2] [formats:3] [rules:4] */
......@@ -300,6 +301,19 @@ static int zlog_conf_build_with_file(zlog_conf_t * a_conf)
*++p = '\0';
/* clean the tail comments start from # and not in quotation */
in_quotation = 0;
for (p = line; *p != '\0'; p++) {
if (*p == '"') {
in_quotation ^= 1;
continue;
}
if (*p == '#' && !in_quotation) {
*p = '\0';
}
}
/* we now have the complete line,
* and are positioned at the first non-whitespace
* character. So let's process it
......
......@@ -4,23 +4,11 @@
default format = "%d.%us %-6V %p:%T:%F:%L %m%n"
[rules]
# time ./test_press_zlog 1 10 100000 real user sys
#*.* | /usr/bin/cronolog press%Y%m%d.log
# 2.081s 2.190s 1.420s
*.* "press.log"
# 2.371s 1.850s 2.610s
#*.* "press.log",10M
# 3.088s 2.130s 3.730s
#*.* "press%d(%Y%m%d).log"
# 4.375s 2.290s 5.350s
#*.* "press%d(%Y%m%d).log",1M*5
# 4.602s 2.710s 6.050s
#*.* "press.%d(%F).log",1MB ~ "press.#2r.log"
# 4.774s 2.730s 6.120s
# time ./test_press_zlog 1 10 100000 real user sys
#*.* | /usr/bin/cronolog press%Y%m%d.log #1.632s 2.010s 1.100s
*.* "press.log" #2.364s 2.090s 2.460s
#*.* "press.log",10M #3.079s 2.320s 3.680s
#*.* "press%d(%Y%m%d).log" #4.132s 2.910s 5.030s
#*.* "press%d(%Y%m%d).log",1M*5 #4.713s 2.740s 6.310s
#*.* "press.%d(%F).log",1MB ~ "press.#2r.log"#4.730s 2.690s 6.360s
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment