corinthia-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriela Gibson <>
Subject logger for Corinthia
Date Mon, 17 Aug 2015 21:30:48 GMT

Jan kindly tasked me with making a logger for Corinthia and helped me
figure out what it needed initially.

Currently it only produces a log file and uses a small combination of
macros to write out the file, line and function.  It will acquire function
pointers for users to hook in their own output functions and other stuff
in the next iteration.

However, whilst this still misses a lot of the spec, this is a good
time to take a look to see how this is all going and if what I
concocted here is portable, or even a good idea.

Caveat: I have no clue why I keep getting the complaints from gcc,
it does compile, link and run in the end.[1]

You can find it here:


log_maker.h  // header
log_maker.c  // code for the log mechanism
useLogmaker.c // test code

You probably want to set the log directory to something useful, it's
currently set to tmp/foo/bar, in useLogmaker.c main: 25 in the line

to build and run, it's

$ make; ./logMaker

After the program is completed, it shows a message giving the path and
name of the created log file.


[1] Output on my machine:

gcc -ggdb -std=c99 -Wall    -c -o useLogmaker.o useLogmaker.c
In file included from useLogmaker.c:1:0:
log_maker.h:26:12: warning: ‘global_log_level’ defined but not used
 static int global_log_level = LOG_WARNING;
log_maker.h:28:12: warning: ‘log_level_initialised’ defined but not
used [-Wunused-variable]
 static int log_level_initialised = 0;
gcc -ggdb -std=c99 -Wall    -c -o log_maker.o log_maker.c
log_maker.c: In function ‘log_msg_prefix’:
log_maker.c:183:5: warning: implicit declaration of function ‘dprintf’
     dprintf(log_file_fd, "%s %s %s:%d %s() ", level_prefixes[level],
time_buf, filename, linenum, function);
log_maker.c: In function ‘log_msg’:
log_maker.c:194:5: warning: implicit declaration of function
‘vdprintf’ [-Wimplicit-function-declaration]
     vdprintf(log_file_fd, fmt, argp);
gcc -ggdb -std=c99 -Wall  -o logMaker useLogmaker.o log_maker.o
Logfile created in /tmp/foo/bar/logMaker.musashi.20150813-182555

Visit my Coding Diary:

View raw message