class Poco::LogStream

Overview

This class implements an ostream interface to a Logger. More…

#include <LogStream.h>

class LogStream:
    public Poco::LogIOS,
    public ostream
{
public:
    // construction

    LogStream(
        Logger& logger,
        Message::Priority priority = Message::PRIO_INFORMATION
        );

    LogStream(
        const std::string& loggerName,
        Message::Priority priority = Message::PRIO_INFORMATION
        );

    // methods

    LogStream&
    fatal();

    LogStream&
    fatal(const std::string& message);

    LogStream&
    critical();

    LogStream&
    critical(const std::string& message);

    LogStream&
    error();

    LogStream&
    error(const std::string& message);

    LogStream&
    warning();

    LogStream&
    warning(const std::string& message);

    LogStream&
    notice();

    LogStream&
    notice(const std::string& message);

    LogStream&
    information();

    LogStream&
    information(const std::string& message);

    LogStream&
    debug();

    LogStream&
    debug(const std::string& message);

    LogStream&
    trace();

    LogStream&
    trace(const std::string& message);

    LogStream&
    priority(Message::Priority priority);
};

Inherited Members

public:
    // methods

    LogStreamBuf*
    rdbuf();

protected:
    // fields

    LogStreamBuf _buf;

Detailed Documentation

This class implements an ostream interface to a Logger.

The stream’s buffer appends all characters written to it to a string. As soon as a CR or LF (std::endl) is written, the string is sent to the Logger, with the current priority.

Usage example:

LogStream ls(someLogger);
ls << "Some informational message" << std::endl;
ls.error() << "Some error message" << std::endl;

Construction

LogStream(
    Logger& logger,
    Message::Priority priority = Message::PRIO_INFORMATION
    )

Creates the LogStream, using the given logger and priority.

LogStream(
    const std::string& loggerName,
    Message::Priority priority = Message::PRIO_INFORMATION
    )

Creates the LogStream, using the logger identified by loggerName, and sets the priority.

Methods

LogStream&
fatal()

Sets the priority for log messages to Message::PRIO_FATAL.

LogStream&
fatal(const std::string& message)

Sets the priority for log messages to Message::PRIO_FATAL and writes the given message.

LogStream&
critical()

Sets the priority for log messages to Message::PRIO_CRITICAL.

LogStream&
critical(const std::string& message)

Sets the priority for log messages to Message::PRIO_CRITICAL and writes the given message.

LogStream&
error()

Sets the priority for log messages to Message::PRIO_ERROR.

LogStream&
error(const std::string& message)

Sets the priority for log messages to Message::PRIO_ERROR and writes the given message.

LogStream&
warning()

Sets the priority for log messages to Message::PRIO_WARNING.

LogStream&
warning(const std::string& message)

Sets the priority for log messages to Message::PRIO_WARNING and writes the given message.

LogStream&
notice()

Sets the priority for log messages to Message::PRIO_NOTICE.

LogStream&
notice(const std::string& message)

Sets the priority for log messages to Message::PRIO_NOTICE and writes the given message.

LogStream&
information()

Sets the priority for log messages to Message::PRIO_INFORMATION.

LogStream&
information(const std::string& message)

Sets the priority for log messages to Message::PRIO_INFORMATION and writes the given message.

LogStream&
debug()

Sets the priority for log messages to Message::PRIO_DEBUG.

LogStream&
debug(const std::string& message)

Sets the priority for log messages to Message::PRIO_DEBUG and writes the given message.

LogStream&
trace()

Sets the priority for log messages to Message::PRIO_TRACE.

LogStream&
trace(const std::string& message)

Sets the priority for log messages to Message::PRIO_TRACE and writes the given message.

LogStream&
priority(Message::Priority priority)

Sets the priority for log messages.