---
name: "syslogbuf"
section: "3bobcat"
platform: "linux"
package: "libbobcat-dev"
version: "6.07.01-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/syslogbuf"
---

# syslogbuf(3bobcat)

A streambuf object inserting syslog messages

## NAME

FBB::SyslogBuf - A streambuf object inserting syslog messages

## SYNOPSIS

**#include \<bobcat/syslogbuf\>**\
 Linking option: *-lbobcat*

## DESCRIPTION

Addresses of **FBB::SyslogBuf** objects can be passed as **std::streambuf** addresses to *std::ostream* objects to write messages to the syslog daemon using stream facilities.

Multiple separate insertions can be used to create a single syslog message: the message is only sent to the syslog daemon after receiving a *flush* command (e.g., after inserting *std::flush* or *std::endl*). Non-printable characters (like *’\\n’*) show up in the syslog message as octal values, preceded by *#* (e.g., *#012* for *’\\n’*). The newline normally inserted by *std::endl* is ignored: **SyslogStream** objects interpret *std::endl* like *std::flush*.

One series of insertions may contain multiple *std::endl* or *std::flush* manipulators. At each of these manipulators a new message is sent to the syslog daemon, containing all info that has so far been buffered. After sending a message to the syslog daemon, the **SyslogStream**’s internal buffer is cleared.

## NAMESPACE

**FBB**\
 All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace **FBB**.

## INHERITS FROM

*FBB::EoiBuf* and thus from *std::streambuf*

## ENUMERATIONS

The following enumerations are defined in the namespace **FBB**:

**Priority**:

The values of this enumeration match the corresponding priority **LOG\_xxx** values used with [**syslog**(3)](/syslog/3.md):

- o

  **EMERG**:\
   system is unusable;

- o

  **ALERT**:\
   action must be taken immediately;

- o

  **CRIT**:\
   critical conditions;

- o

  **ERR**:\
   error conditions;

- o

  **WARNING**:\
   warning conditions;

- o

  **NOTICE**:\
   normal, but significant, condition;

- o

  **INFO**:\
   informational message;

- o

  **DEBUG**:\
   debug-level message;

**PriorityType**:

This enumeration has two values fine-tuning the type of messages that are actually processed by the syslog daemon:

- o

  **SINGLE**:\
   Only messages of the priority specified at the *setMask* call are processed by the syslog daemon;

- o

  **UPTO**:\
   Messages of priority *EMERG* up to the the priority specified at the *setMask* call are processed by the syslog daemon; By default, the syslog daemon processes all messages it receives.

**Facility**:

The values of this enumeration match the corresponding facility **LOG\_xxx** values used with [**syslog**(3)](/syslog/3.md):

- o

  **AUTHPRIV**:\
   security/authorization messages (private)

- o

  **CRON**:\
   clock daemon (*cron* and *at*)

- o

  **DAEMON**:\
   other system daemons

- o

  **KERN**:\
   kernel messages

- o

  **LOCAL0**:\
   reserved for local use. **LOCAL1** through **LOCAL7** are available as well.

- o

  **LPR**:\
   line printer subsystem

- o

  **MAIL**:\
   mail subsystem

- o

  **NEWS**:\
   *USENET* news subsystem

- o

  **SYSLOGBUF**:\
   messages generated internally by *syslogbufd*

- o

  **USER**:\
   generic user-level messages

- o

  **UUCP**:\
   UUCP subsystem

## CONSTRUCTOR

- o

  **SyslogBuf(string const &ident = "",** **FBB::Priority priority = FBB::NOTICE,** **FBB::Facility facility = FBB::USER,** **int option = 0)**:\
   The *ident* parameter is usually the name of the program. Its content are prepended to syslog messages.

-

  The *priority* parameter determines the default importance of the message sent to the syslog daemon. By default messages are sent to the syslog daemon with priority **FBB::NOTICE**. Syslog messages may be given different priority by inserting a **SyslogStream**(3bobcat) manipulator. The priority set at construction time may also be modified using the *setPriority* and *setDefaultPriority* members.

-

  Which messages actually appear in log facilities is not determined 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 determines the type of program doing the logging. By default **FBB::USER** is used.

-

  The *option* parameter may be used to specify various options (use the binary \`*bitor*’ (\`*\|*’) operator to combine options):

-

  **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 con- nection 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.

## MEMBER FUNCTIONS

All members of **std::streambuf** are available, as **FBB::SyslogBuf** inherits from this class.

- o

  **Priority defaultPriority() const**:\
   Returns the current default priority. I.e., the priority that will be used for the messages after inserting *endl* or *flush*.

- o

  **void eoi()**:\
   If the **SyslogStream**’s internal buffer is not empty it is flushed to the syslog daemon. Thereafer [**closelog**(3)](/closelog/3.md) is called. Instead of using this member the *eoi* manipulator can also be used.

- o

  **Priority priority() const**:\
   Returns the next priority. I.e., the priority that will be used for the next message that is sent to the syslog daemon.

- o

  **void reset(string const &ident,** **FBB::Priority priority = FBB::NOTICE,** **FBB::Facility facility = FBB::USER,** **int option = 0)**:\
   Redefines the current identifier, priority, facility and options that are used when sending messages to the syslog daemon. If the **SyslogStream**’s internal buffer is not empty it is first flushed to the syslog daemon using the identifier, priority and options that were active just before calling *open*.

- o

  **Priority setDefaultPriority(Priority priority)**:\
   Changes the default priority of the next message that is sent to the syslog daemon after inserting *std::eoln* or *std::flush*. The previously active default priority is returned.

- o

  **Priority setPriority(Priority priority)**:\
   Changes the priority for the next message that is sent to the syslog daemon after inserting *std::eoln* or *std::flush*. Subsequent messages will again use the default priority. The previously active priority setting is returned.

## MANIPULATOR

- o

  **FBB::eoi**:\
   The *eoi* manipulator can be inserted into the *ostream* instead of calling the *SyslogBuf::end* member. It performs the same actions as the *eoi* member.  If inserted into a plain *std::ostream* nothing happens.

## EXAMPLE

See also [**syslogstream**(3bobcat)](/syslogstream/3bobcat.md)

```
#include <iostream>
#include <bobcat/syslogstream>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
{
    ostream sls(new SyslogBuf(argv[0]));
    sls << SyslogStream::debug << "Hello world" << flush <<
           SyslogStream::strerrno << endl;
}
```

## FILES

*bobcat/syslogbuf* - defines the class interface

## SEE ALSO

[**bobcat**(7)](/bobcat/7.md), [**closelog**(3)](/closelog/3.md), [**openlog**(3)](/openlog/3.md), [**rsyslogd**(8)](/rsyslogd/8.md) [**syslog**(3)](/syslog/3.md), [**syslogstream**(3bobcat)](/syslogstream/3bobcat.md)

## BUGS

The constructor’s *option* parameter is an *int*. Because of this, *int* values rather than enumeration values are passed to the constructor. It is the responsibility of the programmer to pass defined option values only.

## BOBCAT PROJECT FILES

- o

  *https://fbb-git.gitlab.io/bobcat/*: gitlab project page;

Debian Bobcat project files:

- o

  *libbobcat6*: debian package containing the shared library, changelog and copyright note;

- o

  *libbobcat-dev*: debian package containing the static library, headers, manual pages, and developer info;

## BOBCAT

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

## COPYRIGHT

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

## AUTHOR

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