Archived
1
0
Fork 0

log.c: Added basic logging support.

This commit is contained in:
Henrik Hautakoski 2010-11-19 11:12:22 +01:00
parent 4a33fa091f
commit dd0f1ae393
4 changed files with 222 additions and 1 deletions

View file

@ -1,6 +1,6 @@
# Test makefile
CC=gcc
CFLAGS=-g -D__DEBUG__
CFLAGS=-g -D__DEBUG__
LDFLAGS=-L/usr/lib64/mysql -lmysqlclient
all : raw_inotify strbuf path rbtree inotify fscrawl queue
@ -57,5 +57,8 @@ fscrawl :
queue :
$(CC) $(CFLAGS) ../src/queue.c t_queue.c -o test_queue
log :
$(CC) $(CFLAGS) ../src/die.c ../src/strbuf.c ../src/xalloc.c ../src/log.c t_log.c -o test_log
clean :
rm -f test_*

28
test/t_log.c Normal file
View file

@ -0,0 +1,28 @@
#include <errno.h>
#include <stddef.h>
#include "../src/log.h"
int main() {
init_log(LOG_INFO | LOG_WARN, NULL);
logmsg(LOG_INFO, "this is stderr");
logmsg(LOG_CRIT, "Should not show");
logerrno(LOG_CRIT, NULL, ENOENT);
init_log(LOG_INFO | LOG_WARN | LOG_CRIT, "./logs/");
logmsg(LOG_INFO, "some info");
logmsg(LOG_WARN, "invalid type '%i'", 3);
logerrno(LOG_CRIT, "malloc", ENOMEM);
logerrno(LOG_CRIT, NULL, ENOENT);
logmsg(LOG_DEBUG, "Should not show");
logmsg(LOG_INFO | LOG_CRIT, "Should not work, can only log to one priority");
return 0;
}