log4tango::FileAppender(3)

πŸ“¦
version 9.3.4 Β· 2 versions
, in debian bookworm

πŸ¦‹ log4tango::FileAppender(3) πŸ¦‹

okay bestie, welcome to the manual page for log4tango::FileAppender, straight out of the log4tango manual. it writes your logs to a file. that's the whole vibe. let's get into it πŸ’…


✨ NAME ✨

log4tango::FileAppender β€” the appender that puts your logs in an actual file, no cap.


🌸 SYNOPSIS 🌸

#include <FileAppender.hh>

Inherits log4tango::LayoutAppender.

Inherited by log4tango::RollingFileAppender.

πŸ‘‘ 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 () β€” Destructor.
  • virtual bool reopen (void) β€” Reopens the logfile.
  • virtual void close (void) β€” Closes the logfile.
  • virtual bool is_valid (void) const β€” Check if the appender is valid.
  • virtual void set_append (bool append) β€” Sets the append vs truncate flag.
  • virtual bool get_append (void) const β€” Gets the value of the 'append' option.
  • virtual void set_mode (mode_t mode) β€” Sets the file open mode.
  • virtual mode_t get_mode () const β€” Gets the file open mode.

🧚 Protected Member Functions

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

πŸŽ€ Protected Attributes

  • const std::string _file_name
  • int _fd
  • int _flags
  • mode_t _mode

πŸ’œ Additional Inherited Members

(this is the little section that tells you there's more stuff waiting for you up in the base class, iykyk 🫢)


🌈 Constructor & Destructor Documentation 🌈

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

Constructs a FileAppender. iconic behavior tbh ✨

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.

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

Constructs a FileAppender to an already open file descriptor. so if you already have an fd sitting there, this one's for you πŸ’–

Parameters

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

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

Destructor. it's giving closure, literally πŸ¦‹


πŸ”₯ Member Function Documentation πŸ”₯

int log4tango::FileAppender::_append (const LoggingEvent & event) [protected], [virtual]

Log in Appender specific way. Subclasses of Appender should implement this method to perform actual logging. it's the "do the thing" method, fr fr.

Parameters

  • event β€” The LoggingEvent to log.

Implements log4tango::Appender.

Reimplemented in log4tango::RollingFileAppender.


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

Closes the logfile. bye bye file πŸ‘‹

Implements log4tango::Appender.


bool log4tango::FileAppender::get_append (void) const [virtual]

Gets the value of the 'append' option.


mode_t log4tango::FileAppender::get_mode (void) const [virtual]

Gets the file open mode.


bool log4tango::FileAppender::is_valid (void) const [virtual]

Check if the appender is valid. vibe check on the appender itself 😌

Returns

  • true if the appender is valid, false otherwise.

Reimplemented from log4tango::Appender.


bool log4tango::FileAppender::reopen (void) [virtual]

Reopens the logfile. This can be useful for logfiles that are rotated externally, e.g. by logrotate. This method is a NOOP for FileAppenders that have been constructed with a file descriptor.

heads up bestie: if you made this appender with a file descriptor, reopen does literally nothing. NOOP. not a single thing. πŸ’€

Returns

  • true if the reopen succeeded.

Reimplemented from log4tango::Appender.


void log4tango::FileAppender::set_append (bool append) [virtual]

Sets the append vs truncate flag. 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().

okay so this is the messy part πŸ™ˆ the file gets opened in the constructor, so calling set_append afterwards is too late for that very first open. the manpage itself says we'd need something like log4j's activateOptions() β€” that's the author's own note, not mine, periodt.

Parameters

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

void log4tango::FileAppender::set_mode (mode_t mode) [virtual]

Sets the file open mode.


⭐ Member Data Documentation ⭐

  • int log4tango::FileAppender::_fd [protected]
  • const std::string log4tango::FileAppender::_file_name [protected]
  • int log4tango::FileAppender::_flags [protected]
  • mode_t log4tango::FileAppender::_mode [protected]

πŸ’– Author πŸ’–

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


and that's the whole page, bestie 🫢 this is Version 5.0.2, dated Thu Dec 5 2024 β€” go forth and log responsibly, mwah πŸ’…πŸŒΈ

πŸ“¦ where this page comes from