log4shib::FileAppender(3)

πŸ“¦ version 2.0.1, in opensuse-leap 16.0

πŸ’Ύ log4shib::FileAppender β€” the manual page, bestie edition πŸŽ€

okay so this is the log4shib::FileAppender(3) page from the log4shib Library Functions Manual, and it's literally the appender that writes your logs to a file. yes, that's the whole vibe. let's get into it ✨


🌸 NAME 🌸

log4shib::FileAppender β€” it's a class! it appends. to files. iykyk πŸ’…


✨ SYNOPSIS ✨

#include <FileAppender.hh>

Inherits log4shib::LayoutAppender.

Inherited by log4shib::RollingFileAppender. (yes, the rolling one is the child, we love a nepo baby πŸ‘‘)

🫢 Public Member Functions

  • FileAppender (const std::string &name, const std::string &fileName, bool append=true, mode_t mode=00644) β€” Constructs a FileAppender.
  • FileAppender (const std::string &name, int fd) β€” Constructs a FileAppender to an already open file descriptor.
  • virtual ~FileAppender () β€” the destructor, she's virtual
  • virtual bool reopen () β€” Reopens the logfile.
  • virtual void close () β€” Closes the logfile.
  • virtual void setAppend (bool append) β€” Sets the append vs truncate flag.
  • virtual bool getAppend () const β€” Gets the value of the 'append' option.
  • virtual void setMode (mode_t mode) β€” Sets the file open mode.
  • virtual mode_t getMode () const β€” Gets the file open mode.

🌈 Public Member Functions inherited from log4shib::LayoutAppender

  • LayoutAppender (const std::string &name) β€” constructor, incoming
  • virtual ~LayoutAppender () β€” destructor, outgoing
  • virtual bool requiresLayout () const β€” Check if the appender requires a layout.
  • virtual void setLayout (Layout *layout=NULL) β€” Set the Layout for this appender.

πŸ¦‹ Public Member Functions inherited from log4shib::AppenderSkeleton

  • virtual ~AppenderSkeleton () β€” Destructor for AppenderSkeleton.
  • virtual void doAppend (const LoggingEvent &event) β€” Log in Appender specific way.
  • virtual void setThreshold (Priority::Value priority) β€” Set the threshold priority of this Appender.
  • virtual Priority::Value getThreshold () β€” Get the threshold priority of this Appender.
  • virtual void setFilter (Filter *filter) β€” Set a Filter for this appender.
  • virtual Filter * getFilter () β€” Get the Filter for this appender.

🧚 Public Member Functions inherited from log4shib::Appender

  • virtual ~Appender () β€” Destructor for Appender.
  • const std::string & getName () const β€” Get the name of this appender.

πŸ’œ Protected Member Functions πŸ’œ

  • virtual void _append (const LoggingEvent &event) β€” Log in Appender specific way.

🌸 Protected Member Functions inherited from log4shib::LayoutAppender

  • Layout & _getLayout () β€” Return the layout of the appender.

🌸 Protected Member Functions inherited from log4shib::AppenderSkeleton

  • AppenderSkeleton (const std::string &name) β€” Constructor for AppenderSkeleton.

🌸 Protected Member Functions inherited from log4shib::Appender

  • Appender (const std::string &name) β€” Constructor for Appender.

πŸŽ€ Protected Attributes πŸŽ€

  • const std::string _fileName β€” the file name, and it's const, so don't even try it
  • int _fd β€” the file descriptor, bestie
  • int _flags β€” the flags
  • mode_t _mode β€” the mode

⭐ Additional Inherited Members ⭐

πŸ¦‹ Public Types inherited from log4shib::LayoutAppender

  • typedef BasicLayout DefaultLayoutType β€” that's the default layout type, iconic

🌈 Static Public Member Functions inherited from log4shib::Appender

  • static Appender * getAppender (const std::string &name) β€” Get a pointer to an exitsing Appender. (yes, "exitsing" β€” that's how the page spells it, i'm not fixing her typo, she's doing great 😭)
  • static bool reopenAll () β€” Call reopen() on all existing Appenders.
  • static void closeAll () β€” Call reopen() on all existing Appenders. (that's what the page says, drink water, don't @ me πŸ’€)

🌟 Constructor & Destructor Documentation 🌟

log4shib::FileAppender::FileAppender (const std::string & name, const std::string & fileName, bool append = true, mode_t mode = 00644)

Constructs a FileAppender. slay.

Parameters

  • name β€” the name of the Appender.
  • fileName β€” the name of the file to which the Appender has to log.
  • append β€” whether the Appender has to truncate the file or just append to it if it already exists. Defaults to 'true'.
  • mode β€” file mode to open the logfile with. Defaults to 00644.

log4shib::FileAppender::FileAppender (const std::string & name, int fd)

Constructs a FileAppender to an already open file descriptor. like, the fd is already out here living its life, we just join the party 🫢

Parameters

  • name β€” the name of the Appender.
  • fd β€” the file descriptor to which the Appender has to log.

log4shib::FileAppender::~FileAppender () [virtual]

the virtual destructor, no notes, she cleans up after herself πŸ’…


πŸ’– Member Function Documentation πŸ’–

void log4shib::FileAppender::_append (const LoggingEvent & event)

[protected], [virtual]

Log in Appender specific way. Subclasses of Appender should implement this method to perform actual logging. (yes bestie, you do the work, this is just the blueprint ✨)

Parameters

  • event β€” The LoggingEvent to log.

Implements log4shib::AppenderSkeleton.

Reimplemented in log4shib::RollingFileAppender.


void log4shib::FileAppender::close () [virtual]

Closes the logfile. bye girl πŸ‘‹

Implements log4shib::AppenderSkeleton.


bool log4shib::FileAppender::getAppend () const [virtual]

Gets the value of the 'append' option.


mode_t log4shib::FileAppender::getMode () const [virtual]

Gets the file open mode.


bool log4shib::FileAppender::reopen () [virtual]

Reopens the logfile. This can be useful for logfiles that are rotated externally, e.g. by logrotate. lowkey the most useful thing here ngl πŸŒ€

⚠️ heads up: this method is a NOOP for FileAppenders that have been constructed with a file descriptor. like, nothing happens. zero. nada. πŸ’€

Returns

true if the reopen succeeded.

Reimplemented from log4shib::AppenderSkeleton.


void log4shib::FileAppender::setAppend (bool append) [virtual]

Sets the append vs truncate flag.

🚨 real talk: NB. currently the FileAppender opens the logfile in the constructor. Therefore this method is too late to influence the first file opening. We'll need something similar to log4j's activateOptions(). so yeah, it's giving "we know, we know" 😭

Parameters

  • append β€” false to truncate, true to append

void log4shib::FileAppender::setMode (mode_t mode) [virtual]

Sets the file open mode.


πŸ“ Member Data Documentation πŸ“

  • int log4shib::FileAppender::_fd [protected]
  • const std::string log4shib::FileAppender::_fileName [protected]
  • int log4shib::FileAppender::_flags [protected]
  • mode_t log4shib::FileAppender::_mode [protected]

πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for log4shib from the source code. (yes, a robot wrote this, and she ate πŸ€–βœ¨)


and that's the page!! 🫢 this was log4shib Version 2.0.1, manual page log4shib::FileAppender(3), bestie β€” go forth and log responsibly πŸ’œπŸ¦‹