.TH "appender_type_stream2.h" 3 "Version 1.2.4" "log4c" \" -*- nroff -*- .ad l .nh .SH NAME appender_type_stream2.h \- Log4c stream2 appender interface\&. .SH SYNOPSIS .br .PP \fC#include \fP .br \fC#include \fP .br .SS "Functions" .in +1c .ti -1c .RI "void \fBlog4c_stream2_set_fp\fP (\fBlog4c_appender_t\fP *a_this, FILE *fp)" .br .ti -1c .RI "FILE * \fBlog4c_stream2_get_fp\fP (\fBlog4c_appender_t\fP *a_this)" .br .ti -1c .RI "void \fBlog4c_stream2_set_flags\fP (\fBlog4c_appender_t\fP *a_this, int flags)" .br .ti -1c .RI "int \fBlog4c_stream2_get_flags\fP (\fBlog4c_appender_t\fP *a_this)" .br .in -1c .SS "Variables" .in +1c .ti -1c .RI "__LOG4C_BEGIN_DECLS const \fBlog4c_appender_type_t\fP \fBlog4c_appender_type_stream2\fP" .br .in -1c .SH "Detailed Description" .PP Log4c stream2 appender interface\&. The stream2 appender uses a file handle \fCFILE*\fP for logging\&. It can be used with \fCstdout\fP, \fCstderr\fP or a normal file\&. It is pretty primitive as it does not do file rotation, or have a maximum configurable file size etc\&. It improves on the stream appender in a few ways that make it a better starting point for new stream based appenders\&. .PP It enhances the stream appender by allowing the default file pointer to be used in buffered or unbuffered mode\&. Also when you set the file pointer stream2 will not attempt to close it on exit which avoids it fighting with the owner of the file pointer\&. stream2 is configured via setter functions--the udata is not exposed directly\&. This means that new options (eg\&. configure the open mode ) could be added to stream2 while maintaining backward compatability\&. .PP The appender can be used with default values, for example as follows: .PP .PP .nf log4c_appender_t* myappender; myappender = log4c_appender_get("/var/logs/mylog\&.log"); log4c_appender_set_type(myappender,log4c_appender_type_get("stream2")); .fi .PP .PP In this case the appender will be configured automatically with default values: .PD 0 .IP "\(bu" 1 the filename is the same as the name of the appender, \fC'/var/logs/mymlog\&.log'\fP .IP "\(bu" 1 the file is opened in 'w+' mode .IP "\(bu" 1 the default system buffer is used (cf; \fCsetbuf()\fP ) in buffered mode .PP The stream2 appender can be configured by passing it a file pointer to use\&. In this case you manage the file pointer yourself--open, option setting, closing\&. If you set the file pointer log4c will not close the file on exiting--you must do this: .PP .PP .nf log4c_appender_t* myappender; FILE * fp = fopen("myfile\&.log", "w"); myappender = log4c_appender_get("myappender"); log4c_appender_set_type(myappender, log4c_appender_type_get("stream2")); log4c_stream2_set_fp(stream2_appender,myfp); .fi .PP .PP The default file pointer can be configured to use unbuffered mode\&. Buffered mode is typically 25%-50% faster than unbuffered mode but unbuffered mode is useful if your preference is for a more synchronized log file: .PP .PP .nf log4c_appender_t* myappender; myappender = log4c_appender_get("/var/logs/mylog\&.log"); log4c_appender_set_type(myappender,log4c_appender_type_get("stream2")); log4c_stream2_set_flags(myappender, LOG4C_STREAM2_UNBUFFERED); .fi .PP .SH "Function Documentation" .PP .SS "int log4c_stream2_get_flags (\fBlog4c_appender_t\fP * a_this)" Get the flags for this appender\&. .PP \fBParameters\fP .RS 4 \fIthis\fP a pointer to the appender .RE .PP \fBReturns\fP .RS 4 the flags for this appender\&. returns -1 if there was a problem\&. .RE .PP .SS "FILE * log4c_stream2_get_fp (\fBlog4c_appender_t\fP * a_this)" Get the file pointer for this appender\&. .PP \fBParameters\fP .RS 4 \fIthis\fP a pointer to the appender .RE .PP \fBReturns\fP .RS 4 the file pointer for this appender\&. If there's a problem returns NULL\&. .RE .PP .SS "void log4c_stream2_set_flags (\fBlog4c_appender_t\fP * a_this, int flags)" Set the flags for this appender\&. .PP \fBParameters\fP .RS 4 \fIthis\fP a pointer to the appender .br \fIflags\fP ar teh flags to set\&. These will overwrite the existing flags\&. Currently supported flags: LOG4C_STREAM2_UNBUFFERED .RE .PP .SS "void log4c_stream2_set_fp (\fBlog4c_appender_t\fP * a_this, FILE * fp)" Set the file pointer for this appender\&. .PP \fBParameters\fP .RS 4 \fIthis\fP a pointer to the appender .br \fIfp\fP the file pointer this appender will use\&. The caller is responsible for managing the file pointer (open, option setting, closing)\&. .RE .PP .SH "Variable Documentation" .PP .SS "__LOG4C_BEGIN_DECLS const \fBlog4c_appender_type_t\fP log4c_appender_type_stream2" Stream2 appender type definition\&. .PP This should be used as a parameter to the log4c_appender_set_type() routine to set the type of the appender\&. .SH "Author" .PP Generated automatically by Doxygen for log4c from the source code\&.