Re: Include miliseconds in logging
Guillaume Cottenceau <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Stipe Tolj <st 'at' tolj.org> writes:
> Vincent CHAVANIS schrieb:
>> ++1 But,
>>
>> with a config var that allow to activate/desactivate it.
>> and by default disabled. So no compatibility breaks
>
> grrr, runtime config? No way, this means we have a "branch check (if
> statement)" for EACH log entry and even ALL debug() stdout calls.
>
> Eather we do a configure config switch --enable-millisecconds or we do
> it default. But no runtime config, as this means runtime checks.
Well, runtime config not necessarily means runtime checks, if you
use a function pointer set at config time.
-=-=---=-=---=-=---=-=---=-=---=-=---=-=--
#include <stdio.h>
#include <string.h>
void log0(char* logentry) {
printf("log0: %s\n", logentry);
}
void log1(char* logentry) {
printf("log1: %s\n", logentry);
}
static void (*logger)(char*);
int main (int argc, char** argv)
{
if (!strcmp(argv[1], "log0"))
logger = &log0;
else
logger = &log1;
logger("hello world");
return 0;
}
-=-=---=-=---=-=---=-=---=-=---=-=---=-=--
[gc@meuh /tmp] gcc -Wall t.c && ./a.out log0 && ./a.out log1
log0: hello world
log1: hello world
--
Guillaume Cottenceau, MNC Mobile News Channel SA, an Alcatel-Lucent Company
Av. de la Gare 10, 1003 Lausanne, Switzerland - direct +41 21 317 50 36