From 60191039417f2669e3302d00adbbaef18136b8b5 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Wed, 3 Nov 2010 16:04:11 +0000 Subject: [PATCH] --- lsyncd.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/lsyncd.c b/lsyncd.c index 561cede..26a1b81 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -179,7 +179,7 @@ static char * s_strdup(const char *src); /** * if true logs everything */ -bool logall = true; +bool logall = false; /* core logs with CORE flag */ #define logstring(cat, message) \ @@ -243,6 +243,10 @@ static void add_logcat(const char *name, int priority) { struct logcat *lc; + if (!strcmp("all", name)) { + logall = true; + return; + } /* category must start with capital letter */ if (name[0] < 'A' || name[0] > 'Z') { @@ -1190,9 +1194,25 @@ main(int argc, char *argv[]) /* the Lua interpreter */ lua_State* L; - add_logcat("Debug", LOG_DEBUG); // TODO - add_logcat("Normal", LOG_NOTICE); - add_logcat("Error", LOG_ERR); + { + add_logcat("Normal", LOG_NOTICE); + add_logcat("Error", LOG_ERR); + /* Prepates logging early */ + int i = 1; + while (i < argc) { + if (strcmp(argv[i], "-log") && strcmp(argv[i], "--log")) { + i++; continue; + } + if (++i >= argc) { + break; + } + if (argv[i][0] < 'A' || argv[i][0] > 'Z') { + XXX + } + add_logcat(argv[i], LOG_NOTICE); + } + } + /* position at cores (minimal) argument parsing * * most arguments are parsed in the lua runner */