FBB::LogBuf(3bobcat)

πŸ’– FBB::LogBuf πŸ’– β€” the std::streambuf that handles your log messages

okay so real talk bestie, this is page 3bobcat, and it's all about FBB::LogBuf, a lil class that handles log messages like an absolute queen. let's get into it πŸ’…


✨ NAME ✨

FBB::LogBuf β€” a std::streambuf handling log messages 🫢


✨ SYNOPSIS ✨

#include <bobcat/logbuf>

Linking option: -lbobcat


✨ DESCRIPTION ✨

so FBB::LogBuf is a class derived from std::streambuf that handles log messages. the stream you log to, the timestamps, and the log-levels β€” all of that can be configured at construction time and beyond, like it's literally never too late to change your mind πŸ¦‹. and the way that FBB::LogBuf can be used to initialize a std::ostream? iconic. main character energy fr fr.


✨ NAMESPACE ✨

FBB

bestie, every single constructor, member, operator and manipulator mentioned in this man-page is defined in the namespace FBB. no cap.


✨ INHERITS FROM ✨

std::streambuf


✨ ENUMERATIONS ✨

the TimeStamps enum 🌸

The enumeration TimeStamps is defined in the namespace FBB and it's there for you to use when initializing FBB::LogBuf objects. it has these values:

  • NOTIMESTAMPS β€” log-messages will not have timestamps prepended to them. zero timestamps, none, nada πŸ™ˆ
  • TIMESTAMPS β€” log-messages will have timestamps prepended to them ⭐
  • UTCTIMESTAMPS β€” log-messages will have timestamps showing the UTC time prepended to them 🌈

the Active enum πŸŽ€

The enumeration Active is used to distinguish between two whole moods: suspending message insertion when a message's level does not exceed a minimum level, versus suspending all message insertions (e.g., when suspending inserting messages into FBB::Log objects after calling their off member). it's giving ✨boundaries✨:

  • OFF β€” all insertions into the LogBuf object are suspended πŸ’€;
  • NOT_ACTIVE β€” insertions of messages into the LogBuf object are suspended if their levels are less than the a specified minimum (as set by, e.g., Log::setLevel).
  • ACTIVE β€” messages are inserted πŸ”₯

✨ CONSTRUCTORS ✨

  • LogBuf(TimeStamps timestamps = TIMESTAMPS, bool active = true, char const *delim = " ") β€” this constructor constructs an FBB::LogBuf object writing its log-messages to std::cerr. If the active parameter is initialized to false then no messages will be logged until the buffer's activity is switched on (see setActive() below). The parameter delim is inserted immediately beyond the time stamp. If a delimiter is inappropriate, an empty string or a 0-pointer may be specified. When stamps == FBB::NOTIMESTAMPS then delim is ignored. A time stamp consists of the month, the day number of the month and the (local) time of the current message, as usually appearing in messages in /var/log files. E.g., Aug 5 13:52:23;
  • LogBuf(std::ostream &stream, TimeStamps timestamps = TIMESTAMPS, bool active = true, char const *delim = " ") β€” this constructor constructs an FBB::LogBuf object writing its log-messages to the stream used to initialize its stream parameter. If the active parameter is initialized to false then no messages will be logged until the buffer's activity is switched on (see setActive() below). The parameter delim is inserted immediately beyond the time stamp. If a delimiter is inappropriate, an empty string or a 0-pointer may be specified. When stamps == FBB::NOTIMESTAMPS then delim is ignored. A time stamp consists of the month, the day number of the month and the (local) time of the current message, as usually appearing in messages in /var/log files. E.g., Aug 5 13:52:23.
not me about to break your heart but: copy and move constructors (and assignment operators) are not available. 🚫

✨ PUBLIC MEMBER FUNCTIONS ✨

all members of std::streambuf are available, because FBB::LogBuf inherits from this class. you get the whole family πŸ’œ

  • bool active() const β€” returns true if log-messages are currently processed;
  • bool empty() const β€” returns true if the object's buffer is currently empty (initially or after a newline character has been inserted);
  • void setStream(std::ostream &stream) β€” this member may be used to switch the stream to log to. It is the responsibility of the programmer to ensure that the external stream remains available for as long as log-messages are inserted into it. like, keep it alive bestie, that's on you 🫢;
  • void settimestamp(FBB::TimeStamps timestamps, char const *delim = " ") β€” the member function (de)activates time stamp prepending. Use the value FBB::TIMESTAMPS to prepend time stamps, FBB::NOTIMESTAMPS suppresses time stamps. A time stamp consists of the month, the day number of the month and the (local) time of the current message, as usually appearing in messages in /var/log files. E.g., Aug 5 13:52:23. The parameter delim is inserted immediately beyond the time stamp. If a delimiter is inappropriate, an empty string or a 0-pointer may be specified. When stamps == FBB::NOTIMESTAMPS then delim is ignored;
  • void setActive(bool active) β€” unless the current object's Active state is OFF this member can be used to (de)activate logging. The argument true activates logging, the argument false deactivates it. If the current Active status is OFF then this member does not change the object's activity status. This member is normally called by FBB::Log::level members;
  • void setActive(Active active) β€” the member function (de)activates logging. The argument ACTIVE activates logging, the argument OFF completely suppresses logging, the argument NOT_ACTIVE also suppresses logging, but here setActive(true) can also be used reactivate logging;
  • void setEmpty(bool empty) β€” this member may be called to ensure that a timestamp is inserted before the next insertion. It is called as setEmpty(true) when a newline character (\n) is inserted, ensuring that another timestamp is prepended before the next insertion. πŸ•

✨ EXAMPLE ✨

okay here's the whole vibe in code, copy it exactly bestie:

#include <iostream>
#include <iomanip>

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

using namespace std;
using namespace FBB;

int main()
{
    LogBuf buffer(cout, FBB::TIMESTAMPS);
    ostream log(&buffer);

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

    buffer.setActive(false);

    log << "one line\n";
    log << "more lines ";
    log << fnl;
    log << "another\n";

    buffer.setActive(true);
    log << "and active again\n";
    log << "another log msg\n";
}

✨ FILES ✨

  • bobcat/logbuf β€” defines the class interface πŸ¦‹

✨ SEE ALSO ✨

bobcat(7), log(3bobcat)


✨ BUGS ✨

None Reported. ✨ (we love a clean bill of health)


✨ BOBCAT PROJECT FILES ✨

Debian Bobcat project files:

  • 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 ✨

Bobcat is an acronym of Brokken's Own Base Classes And Templates. iykyk πŸ‘‘


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


✨ AUTHOR ✨

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


and that's the whole page bestie, slay πŸ’… thanks for reading, mwah 🫢 this was libbobcat-dev_6.15.01, dated 2005-2026, and yes she's been serving since 2005, periodt πŸ’–

πŸ“¦ where this page comes from