Makefile: add test.o to clean
[flog.git] / test.c
blob273c4c8297cf9e59d9e43f76ec6a41986d084afa
1 //! Simple example program
3 #include "flog.h"
4 #include "flog_output_stdio.h"
5 #include "flog_output_file.h"
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <errno.h>
11 int main(void)
13 FLOG_T *log_main,*log_subfunc;
14 printf("-[flog test start]-\n");
16 //create logs
17 log_main = create_flog_t(__func__,FLOG_ACCEPT_DEEP_DEBUG);
18 log_main->error_log=log_main;
19 log_subfunc = create_flog_t("subfunc",FLOG_ACCEPT_DEEP_DEBUG);
20 log_subfunc->error_log=log_main;
21 flog_append_sublog(log_subfunc,log_main);
22 #ifdef FLOG_CONFIG_OUTPUT_STDIO
23 FLOG_T *log_stdout,*log_stderr;
24 log_stdout = create_flog_output_stdout("stdout",FLOG_ACCEPT_ONLY_ERROR);
25 log_stdout->error_log=log_main;
26 flog_append_sublog(log_main,log_stdout);
27 log_stderr = create_flog_output_stderr("stderr",FLOG_ACCEPT_ALL);
28 log_stderr->error_log=log_main;
29 flog_append_sublog(log_main,log_stderr);
30 #endif
31 #ifdef FLOG_CONFIG_OUTPUT_FILE
32 FLOG_T *log_file;
33 log_file = create_flog_output_file("file",FLOG_ACCEPT_ALL,"test.log");
34 log_file->error_log=log_main;
35 flog_append_sublog(log_main,log_file);
36 #endif
38 flog_print(log_subfunc,"print_test",FLOG_ERROR,0,"testing...");
39 flog_printf(log_subfunc,"printf_test",FLOG_INFO,0,"testing... %d %d %d",1,2,3);
41 flog_print(log_subfunc,NULL,FLOG_ERROR,FLOG_MSG_MARK,NULL);
42 flog_print(log_subfunc,NULL,FLOG_ERROR,ENOMEM,NULL);
44 flog_assert(log_subfunc,1+1);
45 //flog_assert(log_subfunc,1-1);
47 #ifdef DEBUG
48 printf("-[flog test suite]-\n");
49 flog_test(log_main);
50 #endif
52 //int i;
53 //for(i=0;i<10000000;i++)
54 //flog_print(log_subfunc,NULL,FLOG_DEEP_DEBUG,FLOG_MSG_MARK,NULL);
55 //clean up
56 destroy_flog_t(log_subfunc);
57 destroy_flog_t(log_main);
58 #ifdef FLOG_CONFIG_OUTPUT_STDIO
59 destroy_flog_t(log_stdout);
60 destroy_flog_t(log_stderr);
61 #endif
62 #ifdef FLOG_CONFIG_OUTPUT_FILE
63 destroy_flog_output_file(log_file);
64 #endif
65 return(0);