1 //! stdio output for Flog
3 //! @file flog_output_stdio.c
4 //! @author Nabeel Sowan (nabeel.sowan@vibes.se)
6 //! When you want flog to write to stdout or stderr
9 #include "flog_output_stdio.h"
11 #ifdef FLOG_CONFIG_OUTPUT_STDIO
13 #include "flog_string.h"
18 //! Output function for log output to stdout
21 int flog_output_stdout(FLOG_T
*log
,const FLOG_MSG_T
*msg
)
24 if(flog_get_str_message(&str
,msg
))
26 if(fprintf(stdout
,str
)<0) {
29 flog_print(log
->error_log
,NULL
,FLOG_ERROR
,FLOG_MSG_CANNOT_WRITE_TO_STDOUT
,NULL
);
37 //! Output function for log output to stderr
40 int flog_output_stderr(FLOG_T
*log
,const FLOG_MSG_T
*msg
)
43 if(flog_get_str_message(&str
,msg
))
45 if(fprintf(stderr
,str
)<0) {
48 flog_print(log
->error_log
,NULL
,FLOG_ERROR
,FLOG_MSG_CANNOT_WRITE_TO_STDERR
,NULL
);
56 //! create and return a log that writes to stdout
58 //! @retval NULL error
59 FLOG_T
* create_flog_output_stdout(const char *name
, FLOG_MSG_TYPE_T accepted_msg_type
)
62 if((p
=create_flog_t(name
,accepted_msg_type
))==NULL
)
64 p
->output_func
=flog_output_stdout
;
69 //! create and return a log that writes to stderr
71 //! @retval NULL error
72 FLOG_T
* create_flog_output_stderr(const char *name
, FLOG_MSG_TYPE_T accepted_msg_type
)
75 if((p
=create_flog_t(name
,accepted_msg_type
))==NULL
)
77 p
->output_func
=flog_output_stderr
;
82 #endif //FLOG_CONFIG_OUTPUT_STDIO