archived.c: added code for setting up log.
This commit is contained in:
parent
055825766f
commit
8ad0243c31
2 changed files with 13 additions and 4 deletions
1
Makefile
1
Makefile
|
|
@ -44,6 +44,7 @@ obj += src/path.o
|
||||||
obj += src/strbuf.o
|
obj += src/strbuf.o
|
||||||
obj += src/xalloc.o
|
obj += src/xalloc.o
|
||||||
obj += src/die.o
|
obj += src/die.o
|
||||||
|
obj += src/log.o
|
||||||
|
|
||||||
obj += src/inotify.o
|
obj += src/inotify.o
|
||||||
obj += src/event.o
|
obj += src/event.o
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,8 @@
|
||||||
|
|
||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "util.h"
|
#include "log.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
static dictionary *config = NULL;
|
static dictionary *config = NULL;
|
||||||
|
|
||||||
|
|
@ -92,7 +91,7 @@ static void main_loop() {
|
||||||
if (event == NULL)
|
if (event == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dprint("%s: (%c) %s%s\n", notify_event_typetostr(event),
|
logmsg(LOG_DEBUG, "%s: (%c) %s%s", notify_event_typetostr(event),
|
||||||
event->dir ? 'D' : 'F', event->path, event->filename);
|
event->dir ? 'D' : 'F', event->path, event->filename);
|
||||||
|
|
||||||
if (event->type == NOTIFY_CREATE)
|
if (event->type == NOTIFY_CREATE)
|
||||||
|
|
@ -127,6 +126,15 @@ int main(int argc, char **argv) {
|
||||||
if (load_config(configfile) < 0)
|
if (load_config(configfile) < 0)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
#ifdef __DEBUG__
|
||||||
|
init_log(LOG_ALL, NULL);
|
||||||
|
#else
|
||||||
|
if (iniparser_getboolean(config, "general:uselog", 0)) {
|
||||||
|
char *path = iniparser_getstring(config, "general:logdir", NULL);
|
||||||
|
init_log(LOG_INFO | LOG_WARN | LOG_CRIT, path);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = database_init(config);
|
ret = database_init(config);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
|
||||||
Reference in a new issue