log4tango::AppenderAttachable(3)

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

🌸 NAME 🌸

log4tango::AppenderAttachable β€” the little base class that keeps track of who's listening, bestie. It lives in the log4tango manual, section 3, and it's the whole reason Logger can hold a lil collection of appenders and yeet messages at all of them. πŸ’…


✨ SYNOPSIS ✨

#include <AppenderAttachable.hh>

Inherited by log4tango::Logger.

So like, Logger literally IS one of these. It got it from its mama. πŸ‘‘

πŸ’– Public Member Functions πŸ’–

  • AppenderAttachable () β€” Constructor. The birth. πŸŽ€
  • virtual ~AppenderAttachable () β€” Destructor. The departure. 😭
  • void add_appender (Appender *appender) β€” Adds an Appender.
  • AppenderList get_all_appenders (void) β€” Get all previously added appenders as a vector.
  • Appender * get_appender (const std::string &name) β€” Get an appender by name.
  • bool is_attached (Appender *appender) β€” Returns true if the specified appender is in list of attached appanders, false otherwise.
  • void remove_all_appenders () β€” Removes all appenders for this Logger.
  • void remove_appender (Appender *appender) β€” Remove the appender passed as parameter from the list of appenders.
  • void remove_appender (const std::string &name) β€” Remove the appender with the name passed as parameter from the list of appenders.

🧚 Protected Member Functions 🧚

  • AppenderAttachable (const AppenderAttachable &other)
  • AppenderAttachable & operator= (const AppenderAttachable &other)
These two are protected, meaning the outside world does NOT get to copy you around, no cap. That's between you and your subclasses. πŸ™ˆ

πŸ¦‹ Protected Attributes πŸ¦‹

  • AppenderMap _appenders β€” Appenders repository. The stash. The vault. πŸ’œ
  • threading::Mutex _appendersMutex β€” A mutex to protect the repository against race conditions. Your bodyguard fr fr. πŸ”₯

πŸ‘‘ Constructor & Destructor Documentation πŸ‘‘

log4tango::AppenderAttachable::AppenderAttachable ()

Constructor. That's it, that's the whole vibe β€” you exist now, congrats. 🌈

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

Destructor. It's virtual, which is the fancy way of saying "subclasses, do your own cleanup too bestie, I'm not doing it for you." πŸ’€

log4tango::AppenderAttachable::AppenderAttachable (const AppenderAttachable & other) [protected]

The copy constructor, but make it protected β€” so it's giving "family only, no plus-ones." πŸŽ€


πŸ’… Member Function Documentation πŸ’…

void log4tango::AppenderAttachable::add_appender (Appender * appender)

Adds an Appender. And listen β€” it does nothing if the appender is NULL or already attached. So no double-adding, no drama, the list stays clean. ✨

AppenderList log4tango::AppenderAttachable::get_all_appenders (void)

Get all previously added appenders as a vector. The caller must call 'release' on each Appender in the returned list when it is no longer needed (the Appender class is ref-counted).

Okay so this one MATTERS. You do not just get the list and walk away, bestie. Ref-counted means somebody's counting, and if you don't 'release' each one when you're done, you're the problem. 😭 Do your part.

Appender * log4tango::AppenderAttachable::get_appender (const std::string & name)

Get an appender by name. The caller must call 'release' on the returned Appender when it is no longer needed (the Appender class is ref-counted). Returns 0 if there is no Appender named 'name' currently attached.

Same energy: grab it, use it, 'release' it. And heads up β€” if nobody's home, you get 0 back, not a crash. 🫢

bool log4tango::AppenderAttachable::is_attached (Appender * appender)

Returns true if the specified appender is in list of attached appanders, false otherwise. A vibe check, basically. βœ…

AppenderAttachable & log4tango::AppenderAttachable::operator= (const AppenderAttachable & other) [protected]

The assignment operator. Also protected. Also not for public consumption. We keep it in the family. πŸ’œ

void log4tango::AppenderAttachable::remove_all_appenders (void)

Removes all appenders for this Logger. Nuclear option, but make it tidy. 🧹

void log4tango::AppenderAttachable::remove_appender (Appender * appender)

Remove the appender passed as parameter from the list of appenders.

void log4tango::AppenderAttachable::remove_appender (const std::string & name)

Remove the appender with the name passed as parameter from the list of appenders.

Two flavors of the same move: one by pointer, one by name. Pick your fighter. πŸ₯Š

πŸ“ Member Data Documentation πŸ“

AppenderMap log4tango::AppenderAttachable::_appenders [protected]

Appenders repository. This is where everybody lives. 🏠

threading::Mutex log4tango::AppenderAttachable::_appendersMutex [protected]

A mutex to protect the repository against race conditions. Because multiple threads and zero protection is not the move, ever. πŸ”’


🌟 Author 🌟

Generated automatically by Doxygen for log4tango from the source code.


okay that's the whole page, and yes it was literally generated by a robot and no it does not need your opinion πŸ’– the manual is log4tango, this is Version 5.0.2, dated Thu Dec 5 2024 β€” slay, go read your logs, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from