FBB::Log(3bobcat)

Log messages
(libbobcat-dev_6.02.02)

2005-2022

NAME

FBB::Log - std::ostream handling log messages

SYNOPSIS

#include <bobcat/log>
Linking option: -lbobcat

DESCRIPTION

The class FBB::Log defines an std::ostream using an FBB::LogBuf std::streambuf. It is used to send log-messages to the (r)syslog stream or to a (configurable) file. Refer to the logbuf(3bobcat) man-page for details about LogBuf.

Which (parts of) messages are actually logged can be configured using FBB::level in combination with the Log member setLevel. By default all information that is inserted into a Log object is logged, but level objects (level(3bobcat)) can be inserted specifying insertion `forces' of the information that is subsequently inserted into Log objects. These `forces' are compared to insertion `resistances' that can be specified by Log objects through their setLevel members.

If the level's `force' is equal to or exceeds the Log object's `resistance' then the insertion is performed, otherwise the insertion is ignored. A single insertion statement may contain multiple level calls. If so, then each level call updates the `force' of insertions following the level call.

Information inserted into Log objects without inserting level objects (or before the first level object) is always logged (see also the Examples section).

By default logged messages are prepended by time stamps. Following the time stamps a delimiter (by default a single space character) is inserted. Delimiters are immediately appended to time stamps and inserted messages are immediately appended to delimiters. When specifying text as delimiters consider starting and ending the delimiter's text with space characters to visually separate the delimiter from the time stamp and from the subsequently inserted information.

NAMESPACE

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

INHERITS FROM

std::ostream

ENUMERATIONS

The enumeration TimeStamps is defined in the namespace FBB, primarily for initializing FBB::LogBuf objects. It is used with Log members as well. It has the following values:

The enumeration LogManipulator is used to handle special or exceptional situations through manipulators. It is defined in the namespace FBB and has the following two values:

CONSTRUCTORS

Copy and move constructors (and assignment operators) are not available.

MEMBER FUNCTIONS

All members of std::ostream are available, as Log inherits from this class.

STATIC MEMBERS

OVERLOADED OPERATOR

The following overloaded operator is defined outside of the FBB namespace. It is used to insert an FBB::LogManipulator into a Log object. If the overloaded operator is used in combination with another kind of stream it performs no actions.

EXAMPLE

#include <iostream>
#include <iomanip>

#include <bobcat/log>
#include <bobcat/level>

using namespace std;
using namespace FBB;

int main()
{
//    Log &log = Log::initialize("&1"); // uses the static Log object
    Log log;                        // explicitly defining a Log object
    log.open("/tmp/out");           // or at once: Log log{ "/tmp/out" }

    log << "This message is written to cout" << nl <<
           setw(16) << ' ' << "occupying multiple lines\n";

    log.off();
    log << "This message is not shown\n";
    log << "This message is not shown\n";
    log << fnl;
    log << "This message is not shown\n";

    log.on(2);
    log << "This message is shown\n";

    log << level(0) << "not shown" << level(2) << "shown at level 2\n";
    log << level(3) << "at level(3)" << level(1) << "not shown" << fnl;

    log << "separate new line\n";

    log << level(2) << "in business again\n";
    log << "final line\n";
}

FILES

bobcat/log - defines the class interface

SEE ALSO

bobcat(7), exception(3bobcat), level(3bobcat), logbuf(3bobcat)

BUGS

The nl and fnl manipulators are received by the Log objects' LogBufs as, respectively, characters 0 and 1. Since log files in practice only received printable characters this should not cause any problems.

BOBCAT PROJECT FILES

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).