LOG4C_ROLLINGFILE_MAKE_UDATA(3)

πŸ“¦
version 1.2.4 Β· 5 versions
, in epel 10, fedora 43, fedora 44, ubuntu stonking

πŸ’– appender_type_rollingfile.h β€” Log4c rolling file appender interface πŸ’–

okay bestie, gather round, because this is the log4c rolling file appender interface, and it's honestly kind of iconic. this page lives in the Library Functions Manual, and it's the whole tea on how log4c handles a rotating stack of log files. no cap, it's giving main character energy for your logging setup. ✨


✨ NAME ✨

appender_type_rollingfile.h β€” the Log4c rolling file appender interface, periodt.


🌸 SYNOPSIS 🌸

#include <log4c/defs.h>
#include <log4c/appender.h>
#include <log4c/rollingpolicy.h>

πŸŽ€ Functions

rollingfile_udata_t * rollingfile_make_udata (void)
int rollingfile_udata_set_logdir (rollingfile_udata_t *rfudatap, const
    char *logdir)
int rollingfile_udata_set_files_prefix (rollingfile_udata_t *rfudatap,
    const char *prefix)
int rollingfile_udata_set_policy (rollingfile_udata_t *rfudatap,
    log4c_rollingpolicy_t *policyp)
const char * rollingfile_udata_get_logdir (rollingfile_udata_t
    *rfudatap)
const char * rollingfile_udata_get_files_prefix (rollingfile_udata_t
    *rfudatap)
long rollingfile_get_current_file_size (rollingfile_udata_t *rfudatap)

πŸ¦‹ Variables

__LOG4C_BEGIN_DECLS const log4c_appender_type_t
    log4c_appender_type_rollingfile

πŸ’… Detailed Description πŸ’…

so, the rolling file appender interface. here's the whole vibe:

the rolling file appender runs a logging mechanism that keeps a list of files, and that list has a max number it can hold. it's like a little shelf of log files and somebody keeps shoving new ones on. 🫢

by default the files get written to the current directory, and the logging names follow the pattern log.1, log.2, etc. (yes, exactly that pattern, don't come for me). you can change all of that with the appropriate setter functions, because we love options. ✨

now here's the lowkey dramatic part: if the appender fails to open logfiles for writing, then the messages get logged to stderr β€” like, it's screaming into the void instead. and it will keep trying to open the zero-th file for writing at rollover events, so if at some point it finally succeeds in opening that file, the messages will start appearing in there and they will no longer be sent to stderr. glow up arc fr fr. 😭

switching from logging to one file to logging to the next one? that's called a 'rollover event'. remember that term, there will be a quiz. πŸ“

the policy that decides when a rollover event should happen is called a 'rolling policy'. and a mechanism is provided so you can define different rolling policies β€” mix and match, build your own, slay.

log4c ships with (and defaults to) the classic size-window rollover policy: it triggers a rollover when files reach a maximum size. the first file in the list is always the current file; when a rollover event happens, the files get shifted up by one position in the list β€” and if the number of files in the list has already hit the max, then the oldest file is rotated out of the window. bye bitch, you've been evicted. πŸ‘‹

for more details on the size-win rollover policy, go read the documentation in the rollingpolicy_type_sizewin.h file. it's all there, iykyk.

πŸ”₯ Function Documentation πŸ”₯

πŸ’œ long rollingfile_get_current_file_size (rollingfile_udata_t * rfudatap)

get the prefix string in this rolling file appender configuration. (yes that's what the doc says, we just vibe with it πŸ’€)

Parameters

  • rfudatap β€” the rolling file appender configuration object.

Returns

the current size of the file being logged to.


🌈 rollingfile_udata_t * rollingfile_make_udata (void )

get a new rolling file appender configuration object. brand new, fresh out the box. 🎁

Returns

a new rolling file appender configuration object, otherwise NULL.


⭐ const char * rollingfile_udata_get_files_prefix (rollingfile_udata_t * rfudatap)

get the prefix string in this rolling file appender configuration.

Parameters

  • rfudatap β€” the rolling file appender configuration object.

Returns

the prefix.


🧚 const char * rollingfile_udata_get_logdir (rollingfile_udata_t * rfudatap)

get the logging directory in this rolling file appender configuration.

Parameters

  • rfudatap β€” the rolling file appender configuration object.

Returns

the logging directory.


πŸ“ int rollingfile_udata_set_files_prefix (rollingfile_udata_t * rfudatap, const char * prefix)

set the prefix string in this rolling file appender configuration.

Parameters

  • rfudatap β€” the rolling file appender configuration object.
  • prefix β€” the logging files prfix to use.

Returns

zero if successful, non-zero otherwise.


🌸 int rollingfile_udata_set_logdir (rollingfile_udata_t * rfudatap, const char * logdir)

set the logging directory in this rolling file appender configuration.

Parameters

  • rfudatap β€” the rolling file appender configuration object.
  • logdir β€” the logging directory to set.

Returns

zero if successful, non-zero otherwise.


πŸ‘‘ int rollingfile_udata_set_policy (rollingfile_udata_t * rfudatap, log4c_rollingpolicy_t * policyp)

set the rolling policy in this rolling file appender configuration. this is the one that decides when the whole rollover situation goes down.

Parameters

  • rfudatap β€” the rolling file appender configuration object.
  • policyp β€” the logging files prfix to use. (ngl bestie, the original docs literally say "prfix" here β€” typo and all πŸ’€ β€” but what you're actually handing over is the rolling policy.)

Returns

zero if successful, non-zero otherwise.


πŸŽ€ Variable Documentation πŸŽ€

πŸ’– __LOG4C_BEGIN_DECLS const log4c_appender_type_t log4c_appender_type_rollingfile

rollingfile appender type definition.

you should use this as a parameter to the log4c_appender_set_type() routine to set the type of the appender. that's literally the whole job. set the type, live your truth. ✨


🫢 Author 🫢

Generated automatically by Doxygen for log4c from the source code. (not a human, just a robot doing its little robot best πŸ₯Ί)


and that's the page, bestie!! πŸ’– this was log4c, Version 1.2.4, from the Library Functions Manual β€” appender_t...llingfile.h(3), mwah, obsessed, no notes. go forth and roll those files. πŸŒˆπŸ’…βœ¨

πŸ“¦ where this page comes from