ost::AppLog(3)

πŸ“¦ version 1.8.1, in ubuntu jammy

πŸ’– NAME πŸ’–

ost::AppLog β€” bestie, this is the Application logger. It's a class that implements a logger that can be used by applications to save log file somewhere on the system. That's it, that's the whole vibe. πŸ‘‘

This page is from the Library Functions Manual, and yes, it's ost::AppLog(3). πŸŽ€


✨ SYNOPSIS ✨

#include <applog.h>

Inherits streambuf, and ostream. (Yes, both. Overachiever energy fr fr. πŸ’…)

🌈 Classes

  • class Ident β€” Ident class that represents module name.

🌸 Public Member Functions

  • AppLog (const char *logFileName=NULL, bool logDirectly=false, bool usePipe=false) β€” Constructor for a customized logger.
  • virtual ~AppLog () β€” Destructor.
  • void subscribe () β€” Subscribes the current thread to logger, it reserves thread safe buffer for it.
  • void unsubscribe () β€” Unsubscribes the current thread from logger.
  • void logFileName (const char *FileName, bool logDirectly=false, bool usePipe=false) β€” Allows to set up ost::alog parameters.
  • void close (void) β€” if logDirectly is set it closes the file.
  • void level (Slog::Level enable) β€” Sets the log level.
  • void clogEnable (bool en=true) β€” Enables clog output.
  • void slogEnable (bool en=true) β€” Enables slog output for error level messages.
  • void identLevel (const char *ident, Slog::Level level) β€” Sets the level for that ident.
  • void open (const char *ident) β€” Opens the file if not already and sets ident.
  • virtual int overflow (int c) β€” stream overflow() overload.
  • virtual int sync () β€” stream sync() overload
  • void emerg (const char *format,...) β€” emerg level printf style method, provided for convenience.
  • void alert (const char *format,...) β€” alert level printf style method, provided for convenience.
  • void critical (const char *format,...) β€” critical level printf style method, provided for convenience.
  • void error (const char *format,...) β€” error level printf style method, provided for convenience.
  • void warn (const char *format,...) β€” warn level printf style method, provided for convenience.
  • void notice (const char *format,...) β€” notice level printf style method, provided for convenience.
  • void info (const char *format,...) β€” info level printf style method, provided for convenience.
  • void debug (const char *format,...) β€” debug level printf style method, provided for convenience.
  • AppLog & operator() (const char *ident, Slog::Level level=Slog::levelError) β€” operator to change ident and log level
  • AppLog & operator() (Ident &ident) β€” operator to change ident
  • AppLog & operator() (Slog::Level level) β€” operator to change logging level
  • AppLog & operator<< (AppLog &(*pfManipulator)(AppLog &)) β€” manipulator operator, to change print levels.
  • AppLog & operator<< (ostream &(*pfManipulator)(ostream &)) β€” manipulator operator, to use ostream manipulators (i.e.
  • AppLog & operator<< (Ident &ident) β€” operator <<
  • AppLog & warn (void) β€” warn level
  • AppLog & error (void) β€” error level
  • AppLog & debug (void) β€” debug level
  • AppLog & emerg (void) β€” emerg level
  • AppLog & alert (void) β€” alert level
  • AppLog & critical (void) β€” critical level
  • AppLog & notice (void) β€” notice level
  • AppLog & info (void) β€” info level

πŸ¦‹ Static Public Member Functions

  • static Slog::Level levelTranslate (string name) β€” Translates level from string to Slog::Level, useful for configuration files for instance.

πŸ’œ Protected Member Functions

  • void writeLog (bool endOfLine=true)

πŸ“ Protected Attributes

  • AppLogPrivate * d

⭐ Static Protected Attributes

  • static map< string, Slog::Level > * assoc

πŸŽ€ Friends

  • ostream & operator<< (ostream &out, AppLog &al)

πŸ’« Detailed Description πŸ’«

Application logger is a class that implements a logger that can be used by applications to save log file somewhere on the system. (Yeah, same sentence as NAME, she's consistent, she's iconic. ✨)

It uses ost::slog to write to syslog and std::clog to write to standard output.

It provides either a stream oriented logger or a old printf style one. Both. Choose your fighter. πŸ₯Š

It can be used to log directly on a file or in a spooler like way. Latter uses a ost::ThreadQueue to implement a thread safe access to logger.

It provides a global stream variable called ost::alog. 🫢

It provides an AppLog::Ident class that represents a module name for instance that can be used to tag logs. Logging levels are the same defined into ost::Slog:

  • Slog::levelEmergency
  • Slog::levelAlert
  • Slog::levelCritical
  • Slog::levelError
  • Slog::levelWarning
  • Slog::levelNotice
  • Slog::levelInfo
  • Slog::levelDebugfrom
bestie the original literally has the word "from" glued onto the end of Slog::levelDebug there and I am NOT touching it, that's between the manpage and god πŸ’€ keeping every detail, no cap.

Example of usage:

alog << mod_name << debug << 'Hello world!' << std::endl;

πŸ›  Constructor & Destructor Documentation πŸ› 

ost::AppLog::AppLog (const char * logFileName = NULL, bool logDirectly = false, bool usePipe = false)

Constructor for a customized logger. Make it yours. πŸ’…

Parameters

  • logFileName β€” log file name.
  • logDirectly β€” true to write directly to file, false to use a spooler like logger.
  • usePipe β€” true to use pipe instead of file, false otherwise

virtual ost::AppLog::~AppLog () [virtual]

Destructor. She's done, she's logging off, respectfully. πŸŽ€


πŸ“š Member Function Documentation πŸ“š

void ost::AppLog::alert (const char * format, ...)

alert level printf style method, provided for convenience.

Parameters

  • format β€” printf format

AppLog& ost::AppLog::alert (void) [inline]

alert level

Returns

  • application logger stream

void ost::AppLog::clogEnable (bool en = true)

Enables clog output.

Parameters

  • en β€” true to enable clog output.

void ost::AppLog::close (void)

if logDirectly is set it closes the file. That's the whole thing. Shut the door behind you. πŸšͺ

void ost::AppLog::critical (const char * format, ...)

critical level printf style method, provided for convenience.

Parameters

  • format β€” printf format

AppLog& ost::AppLog::critical (void) [inline]

critical level

Returns

  • application logger stream

void ost::AppLog::debug (const char * format, ...)

debug level printf style method, provided for convenience.

Parameters

  • format β€” printf format

AppLog& ost::AppLog::debug (void) [inline]

debug level

Returns

  • application logger stream

void ost::AppLog::emerg (const char * format, ...)

emerg level printf style method, provided for convenience.

Parameters

  • format β€” printf format

AppLog& ost::AppLog::emerg (void) [inline]

emerg level

Returns

  • application logger stream

void ost::AppLog::error (const char * format, ...)

error level printf style method, provided for convenience.

Parameters

  • format β€” printf format

AppLog& ost::AppLog::error (void) [inline]

error level

Returns

  • application logger stream

void ost::AppLog::identLevel (const char * ident, Slog::Level level)

Sets the level for that ident.

Parameters

  • ident β€” ident (module name for instance).
  • level β€” level

void ost::AppLog::info (const char * format, ...)

info level printf style method, provided for convenience.

Parameters

  • format β€” printf format

AppLog& ost::AppLog::info (void) [inline]

info level

Returns

  • application logger stream

void ost::AppLog::level (Slog::Level enable)

Sets the log level.

Parameters

  • enable β€” log level.

static Slog::Level ost::AppLog::levelTranslate (string name) [inline], [static]

Translates level from string to Slog::Level, useful for configuration files for instance. Valid level names are:

  • 'emerg' for Slog::levelEmergency
  • 'alert' for Slog::levelAlert
  • 'critical' for Slog::levelCritical
  • 'error' for Slog::levelError
  • 'warn' for Slog::levelWarning
  • 'notice' for Slog::levelNotice
  • 'info' for Slog::levelInfo
  • 'debug' for Slog::levelDebug

Parameters

  • name β€” Slog Level name

Returns

  • Slog level value

void ost::AppLog::logFileName (const char * FileName, bool logDirectly = false, bool usePipe = false)

Allows to set up ost::alog parameters.

Parameters

  • FileName β€” log file name.
  • logDirectly β€” true to write directly to file, false to use a spooler like logger.
  • usePipe β€” true to use pipe instead of file, false otherwise

void ost::AppLog::notice (const char * format, ...)

notice level printf style method, provided for convenience.

Parameters

  • format β€” printf format

AppLog& ost::AppLog::notice (void) [inline]

notice level

Returns

  • application logger stream

void ost::AppLog::open (const char * ident)

Opens the file if not already and sets ident.

Parameters

  • ident β€” module name for instance.

AppLog& ost::AppLog::operator() (const char * ident, Slog::Level level = Slog::levelError)

operator to change ident and log level

Parameters

  • ident β€” ident (module name for instance)
  • level β€” new log level

Returns

  • application logger stream

AppLog& ost::AppLog::operator() (Ident & ident) [inline]

operator to change ident

Parameters

  • ident β€” ident (module name for instance)

Returns

  • application logger stream

References ost::AppLog::Ident::c_str().

AppLog& ost::AppLog::operator() (Slog::Level level)

operator to change logging level

Parameters

  • level β€” new log level

Returns

  • application logger stream

AppLog& ost::AppLog::operator<< (AppLog &(*)(AppLog &) pfManipulator)

manipulator operator, to change print levels.

Parameters

  • (* pfManipulator)(AppLog &)

Returns

  • application logger stream

AppLog& ost::AppLog::operator<< (Ident & ident) [inline]

operator <<

Parameters

  • ident β€” module name for instance.

Returns

  • application logger stream

References ost::AppLog::Ident::c_str().

AppLog& ost::AppLog::operator<< (ostream &(*)(ostream &) pfManipulator)

manipulator operator, to use ostream manipulators (i.e. std::endl,...)

Parameters

  • (* pfManipulator)(AppLog &)

Returns

  • application logger stream

virtual int ost::AppLog::overflow (int c) [virtual]

stream overflow() overload.

Parameters

  • c β€” character to be managed

Returns

  • c

void ost::AppLog::slogEnable (bool en = true)

Enables slog output for error level messages.

Parameters

  • en β€” true to enable slog output.

void ost::AppLog::subscribe ()

Subscribes the current thread to logger, it reserves thread safe buffer for it.

virtual int ost::AppLog::sync () [virtual]

stream sync() overload

void ost::AppLog::unsubscribe ()

Unsubscribes the current thread from logger.

void ost::AppLog::warn (const char * format, ...)

warn level printf style method, provided for convenience.

Parameters

  • format β€” printf format

AppLog& ost::AppLog::warn (void) [inline]

warn level

Returns

  • application logger stream

void ost::AppLog::writeLog (bool endOfLine = true) [protected]


ostream& operator<< (ostream & out, AppLog & al) [friend]

πŸŽ€ MEMBER DATA DOCUMENTATION πŸŽ€

okay bestie, this is the backstage area πŸ’… the actual data members chilling inside ost::AppLog. The docs are... minimal, we're literally just getting the declarations and their access levels, no lore, no tea. But we stan a transparent API, so here's exactly what's there:

  • map<string, Slog::Level>* ost::AppLog::assoc β€” [static], [protected] ✨ it's a pointer to a map<string, Slog::Level>, it's static, and it's protected β€” that's the whole vibe, that's all the docs gave us, and we're respecting the mystery πŸ™ˆ
  • AppLogPrivate* ost::AppLog::d β€” [protected] 🌸 a pointer to an AppLogPrivate, marked protected. classic d energy, iykyk. no description attached, just the declaration sitting there being iconic πŸ‘‘
ngl these two are the quiet ones β€” no write-up, no elaboration, just the raw declarations. if you're poking at them, that's between you and the protected keyword, fr fr 😭

πŸ’œ Author

Generated automatically by Doxygen for GNU CommonC++ from the source code. ✨ so yes, a robot wrote this and honestly? she ate 🫢


and that's the whole page, bestie!! this one came from the GNU CommonC++ docs, dated Sun Dec 27 2020 β€” and the manual page itself is ost::AppLog(3) πŸ’– go forth and log responsibly, mwah πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from