config: move log settings to its own section.
This commit is contained in:
parent
dfaa1be71f
commit
ca73aa43ae
3 changed files with 15 additions and 14 deletions
|
|
@ -1,7 +1,8 @@
|
|||
[general]
|
||||
uselog = 0
|
||||
loglevel = INFO, WARNING, CRITCAL
|
||||
logdir = logs
|
||||
|
||||
[log]
|
||||
use = 0
|
||||
level = INFO, WARNING, CRITCAL
|
||||
directory = logs
|
||||
|
||||
[mysql]
|
||||
host = localhost
|
||||
|
|
|
|||
|
|
@ -17,20 +17,20 @@ String ;;
|
|||
Options
|
||||
~~~~~~
|
||||
|
||||
General
|
||||
Log
|
||||
^^^^^^
|
||||
Options available in the general section
|
||||
Options available in the log section
|
||||
|
||||
uselog (Boolean);;
|
||||
use (Boolean);;
|
||||
Turn logging on/off (values are: Y, N, T, F, 1, 0)
|
||||
loglevel (String List);;
|
||||
level (String List);;
|
||||
Set the logging level
|
||||
Options available are: DEBUG, INFO, WARNING, CRITCAL, ALL
|
||||
+
|
||||
NOTE: A comma separated list can be used to specify more than one level.
|
||||
+
|
||||
|
||||
logdir (String);;
|
||||
directory (String);;
|
||||
Specify a logging directory
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -140,9 +140,9 @@ int main(int argc, char **argv) {
|
|||
#ifdef __DEBUG__
|
||||
init_log(LOG_ALL, NULL);
|
||||
#else
|
||||
if (iniparser_getboolean(config, "general:uselog", 0)) {
|
||||
char *strlevel = iniparser_getstring(config, "general:loglevel", NULL);
|
||||
char *path = iniparser_getstring(config, "general:logdir", NULL);
|
||||
if (iniparser_getboolean(config, "log:use", 0)) {
|
||||
char *strlevel = iniparser_getstring(config, "log:level", NULL);
|
||||
char *path = iniparser_getstring(config, "log:directory", NULL);
|
||||
unsigned level = 0;
|
||||
|
||||
if (strlevel) {
|
||||
|
|
@ -157,13 +157,13 @@ int main(int argc, char **argv) {
|
|||
strbuf_trim(*ptr);
|
||||
l = logstrtolvl((*ptr)->buf);
|
||||
if (l == 0)
|
||||
die("config (general:loglevel): unknown log level: %s\n", (*ptr)->buf);
|
||||
die("config (log:level): unknown level: %s\n", (*ptr)->buf);
|
||||
level += l;
|
||||
}
|
||||
strbuf_free_list(list);
|
||||
strbuf_free(&sb);
|
||||
} else {
|
||||
die("config (general:loglevel): no levels defined\n");
|
||||
die("config (log:level): no levels defined\n");
|
||||
}
|
||||
|
||||
init_log(level, path);
|
||||
|
|
|
|||
Reference in a new issue