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