add (incomplete) file output support
[flog.git] / test.c
blobcded30f57ec3fd24283ec948ecfbbb61e8a70dab
1 #include "flog.h"
2 #include "flog_stdio.h"
3 #include <stdio.h>
4 #include <stdlib.h>
6 //simple example program
8 int main(void)
10 FLOG_T *log_main,*log_subfunc,*log_stdout,*log_stderr;
11 printf("-[flog test start]-\n");
13 //create logs
14 log_main = create_flog_t(__func__,FLOG_SHOW_ALL);
15 log_subfunc = create_flog_t("subfunc",FLOG_SHOW_ALL);
16 log_stdout = create_flog_t("stdout",FLOG_SHOW_ALL);
17 log_stderr = create_flog_t("stderr",FLOG_SHOW_ALL);
19 //set output functions
20 log_stdout->output_func=flog_output_stdout;
21 log_stderr->output_func=flog_output_stderr;
23 //append them to eachother
24 flog_append_sublog(log_subfunc,log_main);
25 flog_append_sublog(log_main,log_stdout);
26 flog_append_sublog(log_main,log_stderr);
28 flog_print(log_subfunc,FLOG_ERROR,"print_test","testing...");
29 flog_printf(log_subfunc,FLOG_ERROR,"printf_test","testing... %d %d %d",1,2,3);
31 printf("-[flog test suite]-\n");
32 flog_test(log_main);
34 //clean up
35 destroy_flog_t(log_subfunc);
36 destroy_flog_t(log_main);
37 destroy_flog_t(log_stdout);
38 destroy_flog_t(log_stderr);
39 return(0);