2 #include "flog_stdio.h"
7 //simple example program
11 FLOG_T
*log_main
,*log_subfunc
,*log_stdout
,*log_stderr
,*log_file
;
12 printf("-[flog test start]-\n");
15 log_main
= create_flog_t(__func__
,FLOG_ACCEPT_ALL
);
16 log_subfunc
= create_flog_t("subfunc",FLOG_ACCEPT_ALL
);
17 log_stdout
= create_flog_t("stdout",FLOG_ACCEPT_ONLY_ERROR
);
18 log_stderr
= create_flog_t("stderr",FLOG_ACCEPT_ALL
);
19 log_file
= create_flog_t("file",FLOG_ACCEPT_ALL
);
22 log_main
->error_log
=log_main
;
23 log_subfunc
->error_log
=log_main
;
24 log_stdout
->error_log
=log_main
;
25 log_stderr
->error_log
=log_main
;
26 log_file
->error_log
=log_main
;
28 //set output functions
29 log_stdout
->output_func
=flog_output_stdout
;
30 log_stderr
->output_func
=flog_output_stderr
;
31 log_file
->output_func
=flog_output_file
;
33 //append them to eachother
34 flog_append_sublog(log_subfunc
,log_main
);
35 flog_append_sublog(log_main
,log_stdout
);
36 flog_append_sublog(log_main
,log_stderr
);
37 flog_append_sublog(log_main
,log_file
);
39 flog_print(log_subfunc
,FLOG_ERROR
,"print_test","testing...");
40 flog_printf(log_subfunc
,FLOG_INFO
,"printf_test","testing... %d %d %d",1,2,3);
42 flog_assert(log_subfunc
,1+1);
43 flog_assert(log_subfunc
,1-1);
46 printf("-[flog test suite]-\n");
51 destroy_flog_t(log_subfunc
);
52 destroy_flog_t(log_main
);
53 destroy_flog_t(log_stdout
);
54 destroy_flog_t(log_stderr
);
55 destroy_flog_t(log_file
);