> Wow that is a complicated solution. I though that simple and blackbox
> went well together.
Completely agree, too complex. The logging code I copy into all the
daemons I write is at the opposite end of the spectrum; I doubt it's
possible to be much simpler. (I copy it everywhere because it's too short
and simple to bother with a lib.)
#define DUMP_SIZE (1024 * 1024)
extern char dump_buf[DUMP_SIZE];
extern int dump_point;
extern int dump_wrap;
extern char daemon_debug_buf[256];
void daemon_dump_save(void)
{
int len, i;
len = strlen(daemon_debug_buf);
for (i = 0; i < len; i++) {
dump_buf[dump_point++] = daemon_debug_buf[i];
if (dump_point == DUMP_SIZE) {
dump_point = 0;
dump_wrap = 1;
}
}
}
#define log_debug(fmt, args...) \
do { \
snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \
daemon_dump_save(); \
} while (0)
That's it, just over 20 lines. I also have a function that will write
dump_buf over a unix socket so a command line program can see it while the
daemon is running (that's the only way I ever use it, actually). This is
non-threaded, of course, and corosync will need something more complex,
but the point is you can keep it simple.
Dave
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais