FBB::SyslogStream(3bobcat)

πŸ¦‹ FBB::SyslogStream β€” the syslog output stream, bestie edition πŸ’–

okay so picture this: you're in FBB::SyslogStream(3bobcat) territory, and it's literally the cutest way to talk to syslog. Let's get into it, no cap.


✨ NAME ✨

FBB::SyslogStream β€” an output stream that inserts syslog messages 🌸


✨ SYNOPSIS ✨

#include <bobcat/syslogstream>

Linking option: -lbobcat


✨ DESCRIPTION ✨

FBB::SyslogStream objects can be used just like a std::ostream, except they write syslog messages using all the stream facilities you already know and love. iconic behavior, honestly 🫢

You can stack up multiple separate insertions to build one single syslog message β€” the message only actually heads to the syslog daemon once it gets a flush command (so like, after you insert std::flush or std::endl).

Non-printable characters (think '\n') show up in the syslog message as octal values, preceded by # β€” so for example #012 is what '\n' turns into. And here's the tea: the newline that std::endl would normally insert gets ignored. SyslogStream objects treat std::endl exactly like std::flush. πŸ’…

One series of insertions can hold multiple std::endl or std::flush manipulators, and at each one a whole new message gets sent to the syslog daemon containing everything buffered so far. Once a message is sent, the SyslogStream's internal buffer is cleared. clean slate energy ✨


✨ NAMESPACE ✨

FBB

Every constructor, member, operator and manipulator mentioned in this man-page lives in the namespace FBB. πŸŽ€


✨ INHERITS FROM ✨

std::ostream


✨ ENUMERATIONS ✨

These enumerations are defined in the namespace FBB:

🌈 Priority

These values match up with the corresponding priority LOG_xxx values used with syslog(3):

  • EMERG β€” system is unusable;
  • ALERT β€” action must be taken immediately;
  • CRIT β€” critical conditions;
  • ERR β€” error conditions;
  • WARNING β€” warning conditions;
  • NOTICE β€” normal, but significant, condition;
  • INFO β€” informational message;
  • DEBUG β€” debug-level message; the setMask member (peep below πŸ‘€) can be used to select which type of messages will actually be processed by the syslog daemon.

🌈 PriorityType

This enumeration has two values that fine-tune which type of messages actually get processed by the syslog daemon:

  • SINGLE β€” only messages of the priority specified at the setMask call are processed by the syslog daemon;
  • UPTO β€” messages of priority EMERG up to the priority specified at the setMask call are processed by the syslog daemon; by default, the syslog daemon processes all messages it receives.

🌈 Facility

These values match up with the corresponding facility LOG_xxx values used with syslog(3):

  • AUTHPRIV β€” security/authorization messages (private)
  • CRON β€” clock daemon (cron and at)
  • DAEMON β€” other system daemons
  • KERN β€” kernel messages
  • LOCAL0 β€” reserved for local use. LOCAL1 through LOCAL7 are available as well.
  • LPR β€” line printer subsystem
  • MAIL β€” mail subsystem
  • NEWS β€” USENET news subsystem
  • SYSLOGBUF β€” messages generated internally by syslogbufd
  • USER β€” generic user-level messages
  • UUCP β€” UUCP subsystem

✨ CONSTRUCTORS ✨

  • SyslogStream(string const &ident = "", FBB::Priority priority = FBB::NOTICE, FBB::Facility facility = FBB::USER, int option = 0) β€” this constructor initializes a SyslogStream object. πŸŽ€ The ident parameter is usually the name of the program, and its content gets prepended to syslog messages.

The priority parameter decides the default importance of the message sent to the syslog daemon. By default messages go to the syslog daemon with priority FBB::NOTICE. Syslog messages can be given a different priority by inserting a SyslogStream manipulator (see below). The priority set at construction time can also be changed using the setPriority and setDefaultPriority members.

Which messages actually show up in log facilities is not decided by the messages' priorities, but by syslog's log mask. The log mask can be set by the static member setMask (see below).

The facility parameter decides the type of program doing the logging. By default FBB::USER is used.

The option parameter can be used to specify various options (use the binary bitor (|) operator to combine them):

  • LOG_CONS: write directly to system console if there is an error while sending to system logger
  • LOG_NDELAY: open the connection immediately (normally, the connection is opened when the first message is logged)
  • LOG_PERROR: print to stderr as well
  • LOG__PID: include PID with each message

By default no options are used. ✨

Copy and move constructors (and assignment operators) are not available. sorry bestie, they're just not invited to the party πŸ™ˆ


✨ MEMBER FUNCTIONS ✨

All members of std::ostream are available, since FBB::SyslogStream inherits from this class. πŸ’–

  • void close() β€” if the SyslogStream's internal buffer isn't empty, it gets flushed to the syslog daemon. After that, closelog(3) is called.
  • Priority defaultPriority() const β€” returns the current default priority. Like, the priority that'll be used for messages after inserting endl or flush.
  • void open(string const &ident, FBB::Priority priority = FBB::NOTICE, FBB::Facility facility = FBB::USER, int option = 0) β€” redefines the current identifier, priority, facility and options used when sending messages to the syslog daemon. If the SyslogStream's internal buffer isn't empty, it's first flushed to the syslog daemon using the identifier, priority and options that were active just before calling open.
  • Priority priority() const β€” returns the next priority. i.e., the priority that'll be used for the next message sent to the syslog daemon.
  • Priority setDefaultPriority(Priority priority) β€” changes the default priority of the next message sent to the syslog daemon after inserting std::eoln or std::flush. The previously active default priority is returned. πŸŽ€
  • Priority setPriority(Priority priority) β€” changes the priority for the next message sent to the syslog daemon after inserting std::eoln or std::flush. Subsequent messages will go back to using the default priority. The previously active priority setting is returned.

✨ STATIC MEMBER FUNCTIONS ✨

  • Priority setMask(Priority priority, PriorityMask upTo) β€” syslog messages of (if upTo equals SINGLE) or up to (if upTo equals UPTO) the indicated priority are processed by the syslog daemon.
  • Priority setMask(Priority priority, Priority ...priorities) β€” syslog messages of the priorities passed to setMask are processed by the syslog daemon. At least one priority must be specified. πŸ‘‘
  • Facility stoF(std::string const &name, Facility facility = USER) β€” returns the facility matching the name of the facility provided by name. Facility matching happens case insensitively. so like, if name contains daemon, facility FBB::DAEMON is returned. If name doesn't match any facility name, then the value of this function's second argument is returned. The function's name (stoF) was chosen in analogy of the various sto... conversion functions that the C++11 standard made available. πŸ’…
  • Priority stoP(std::string const &name, Priority priority = NOTICE) β€” returns the priority matching the name of the priority provided by name. Priority matching happens case insensitively. e.g., if name contains emerg, priority FBB::EMERG is returned. If name doesn't match any priority name, then the value of this function's second argument is returned. The function's name (stoP) was chosen in analogy of the various sto... conversion functions that the C++11 standard made available. ✨

✨ MANIPULATORS ✨

This next set of manipulators are all defined as (static) members. They can be inserted into an FBB::SyslogStream object. Except for the last manipulator (strerrno), they all share these characteristics in common:

  • They change the priority of the messages that are subsequently inserted by the FBB::SyslogStream object β€” so they act like a separate setPriority call.
  • When you insert multiple manipulators before the inserted message is flushed (e.g., using std::flush or std::endl), the last inserted FBB::SyslogStream manipulator will be used.
  • If the manipulators are inserted into something that isn't an FBB::SyslogStream object (like some other std::ostream type of object), then they perform no action at all. πŸ’€

Here are the available manipulators:

  • SyslogStream::alert β€” messages are inserted with priority FBB::ALERT.
  • SyslogStream::crit β€” messages are inserted with priority FBB::CRIT.
  • SyslogStream::debug β€” messages are inserted with priority FBB::DEBUG.
  • SyslogStream::emerg β€” messages are inserted with priority FBB::EMERG.
  • SyslogStream::err β€” messages are inserted with priority FBB::ERR.
  • SyslogStream::info β€” messages are inserted with priority FBB::INFO.
  • SyslogStream::notice β€” messages are inserted with priority FBB::NOTICE.
  • SyslogStream::strerrno β€” this manipulator inserts the textual interpretation of std::errno's current value into a std::ostream. Heads up though: unlike the other manipulators, the object you insert this one into does not have to be an FBB::SyslogStream object. πŸ¦‹
  • SyslogStream::warning β€” messages are inserted with priority FBB::WARNING.

✨ EXAMPLE ✨

#include <bobcat/syslogstream>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
{
    SyslogStream sls(argv[0]);

    sls << SyslogStream::debug << "Hello world" << flush <<
           SyslogStream::strerrno << endl;
}

✨ FILES ✨

bobcat/syslogstream β€” defines the class interface


✨ SEE ALSO ✨

bobcat(7), closelog(3), log(3bobcat), openlog(3), rsyslogd(8), syslog(3), syslogbuf(3bobcat)


✨ BUGS ✨

The constructor's option parameter is an int. Because of this, int values rather than enumeration values get passed to the constructor. So it's πŸ’― the responsibility of the programmer to pass defined option values only. no cap, be careful bestie 😭


🌈 BOBCAT PROJECT FILES 🌈

okay bestie, if you wanna go straight to the source (literally), here's where all the bobcat goodies live:

  • https://fbb-git.gitlab.io/bobcat/ β€” the gitlab project page, your one-stop shop, the mothership, iykyk;
  • Debian Bobcat project files, aka the distro-specific lore:
    • libbobcat6 β€” debian package containing the shared library, changelog and copyright note;
    • libbobcat-dev β€” debian package containing the static library, headers, manual pages, and developer info;

πŸ‘‘ BOBCAT πŸ‘‘

fun fact time, because the name is lowkey a whole personality:

Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.

like… the audacity, the branding, the main character energy. obsessed. ✨


This is free software, distributed under the terms of the GNU General Public License (GPL).

free as in freedom, and legally official, no cap. 🫢


πŸ¦‹ AUTHOR πŸ¦‹

Frank B. Brokken (f.b.brokken@rug.nl).

the icon, the legend, the reason this whole thing exists. bow down. πŸ‘‘


anyway bestie that's the whole page, you made it to the end and i'm so proud of you πŸ’œ this was libbobcat-dev_6.15.01, dated 2005-2026, and yes it's the real FBB::SyslogStream(3bobcat) manpage β€” go forth and log stuff responsibly, mwah πŸ’…πŸŒΈ

πŸ“¦ where this page comes from