Statistics
| Branch: | Revision:

napa-baselibs / tests / log / logtest.c @ 507372bb

History | View | Annotate | Download (1016 Bytes)

1 956892f0 ArpadBakay
/*
2 507372bb CsabaKiraly
 * Log test and demo application for the logging facilities of the NAPA framework.
3 956892f0 ArpadBakay
 *
4 507372bb CsabaKiraly
 * There are 2 ways of calling napa_log:
5
 *         - napa_log(SEVERITY, format, args...)
6 956892f0 ArpadBakay
 *        - or use one of the convenience macros like debug(format, args...) or info(format, args...) as shown below.
7
 *
8
 */
9
10 507372bb CsabaKiraly
#include        <napa_log.h>                /* You must include napa_log.h in order to use napa logging */
11 956892f0 ArpadBakay
12
#include        <math.h>                /* This one is just for fun */
13
14
int main(int argc, char *argv) {
15
16 507372bb CsabaKiraly
        napa_log(LOG_INFO, "You won't see this as logging is not initialized");
17 956892f0 ArpadBakay
18
        /* Initialize logging */
19 507372bb CsabaKiraly
        napaInitLog(-1, NULL, NULL);
20 956892f0 ArpadBakay
21 507372bb CsabaKiraly
        napa_log(LOG_WARN,"Warning! Here I come!");
22 956892f0 ArpadBakay
23 507372bb CsabaKiraly
        napa_log(LOG_INFO,"Hey! This is my %dst %s message", 1, "INFO");
24 956892f0 ArpadBakay
        info("And here comes the %dnd, just much simpler", 2);
25
26
        error("And this is an error message");        
27
28 507372bb CsabaKiraly
        napaCloseLog();
29 956892f0 ArpadBakay
30
        info("Invisible again, as logging is closed");
31
32 507372bb CsabaKiraly
        napaInitLog(-1, NULL, NULL);
33 956892f0 ArpadBakay
34
        debug("Next, I'm going to fatally die...");
35
36
        fatal("Unrecoverable error %lf, exiting...", M_PI);
37
38
        return 0;
39
}