appender_type_stream2.h(3)
π appender_type_stream2.h β Library Functions Manual π
okay so this page is appender_type_stream2.h(3), straight out of the log4c Library Functions Manual, and bestie it's all about the stream2 appender. buckle up, it's short, it's sweet, and it's lowkey iconic π¦
β¨ NAME β¨
appender_type_stream2.h β the Log4c stream2 appender interface. that's it, that's the name, periodt π
πΈ SYNOPSIS πΈ
#include <log4c/defs.h>
#include <log4c/appender.h>
π Functions
void log4c_stream2_set_fp (log4c_appender_t *a_this, FILE *fp)FILE * log4c_stream2_get_fp (log4c_appender_t *a_this)void log4c_stream2_set_flags (log4c_appender_t *a_this, int flags)int log4c_stream2_get_flags (log4c_appender_t *a_this)
π Variables
__LOG4C_BEGIN_DECLS const log4c_appender_type_t log4c_appender_type_stream2
π¦ Detailed Description π¦
Log4c stream2 appender interface, round two, and honestly? she's serving.
The stream2 appender uses a file handle FILE* for logging. it can be used with stdout, stderr, or just a normal file β no cap. she is pretty primitive though, bestie: no file rotation, no maximum configurable file size, none of that. but she improves on the stream appender in a few ways that make her a way better starting point for new stream based appenders π
here's the glow-up: stream2 enhances the stream appender by letting the default file pointer 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, and honestly? no drama, we love to see it π. stream2 is configured via setter functions β the udata is not exposed directly. that means new options (eg. configure the open mode) could be added to stream2 while maintaining backward compatability. forward thinking queen π
The appender can be used with default values, for example as follows:
log4c_appender_t* myappender;
myappender = log4c_appender_get("/var/logs/mylog.log");
log4c_appender_set_type(myappender,log4c_appender_type_get("stream2"));
In this case the appender will be configured automatically with default values:
- the filename is the same as the name of the appender,
"/var/logs/mymlog.log" - the file is opened in
"w+"mode - the default system buffer is used (cf;
setbuf()) in buffered mode
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. all you, bestie. If you set the file pointer, log4c will not close the file on exiting β you must do this:
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);
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:
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);
π Function Documentation π
int log4c_stream2_get_flags (log4c_appender_t * a_this)
Get the flags for this appender. give me the tea, what flags she got πΈ
Parameters
- this β a pointer to the appender
Returns
- the flags for this appender. returns
-1if there was a problem π
FILE * log4c_stream2_get_fp (log4c_appender_t * a_this)
Get the file pointer for this appender. where's the file at, bestie π₯
Parameters
- this β a pointer to the appender
Returns
- the file pointer for this appender. If there's a problem returns
NULLπ
void log4c_stream2_set_flags (log4c_appender_t * a_this, int flags)
Set the flags for this appender. setting the vibe, literally β¨
Parameters
- this β a pointer to the appender
- flags β ar teh flags to set (yes, that's exactly what the page says and we're keeping it fr fr π
). These will overwrite the existing flags. Currently supported flags:
LOG4C_STREAM2_UNBUFFERED
void log4c_stream2_set_fp (log4c_appender_t * a_this, FILE * fp)
Set the file pointer for this appender.
Parameters
- this β a pointer to the appender
- fp β the file pointer this appender will use. The caller is responsible for managing the file pointer (open, option setting, closing).
bestie, read that again: you own the file pointer. open it, set it up, close it. log4c is not gonna do it for you, and she said what she said π«Ά
π Variable Documentation π
__LOG4C_BEGIN_DECLS const log4c_appender_type_t log4c_appender_type_stream2
Stream2 appender type definition.
This should be used as a parameter to the log4c_appender_set_type() routine to set the type of the appender. that's the whole assignment, main character energy π
π Author π
Generated automatically by Doxygen for log4c from the source code. (not a human, just a very diligent little robot π§)
and that's the page, bestie β slay π this whole thing came to you from log4c, Version 1.2.4, and yes the header and footer said the same thing, so here we are, mwah πβ¨π¦π
π¦ where this page comes from
- fedora 43: log4c-devel 1.2.4-34.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: log4c-devel 1.2.4-34.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: log4c-devel 1.2.4-35.fc44 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: log4c-devel 1.2.4-35.fc44 Β· LicenseRef-Callaway-LGPLv2+
- ubuntu stonking: liblog4c-doc 1.2.4-6
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms