senf::log::IOStreamTarget Class Reference

Write log messages to arbitrary std::ostream. More...

#include <senf/Utils/Logger/IOStreamTarget.hh>

Inheritance diagram for senf::log::IOStreamTarget:

Public Member Functions

std::ostream & stream () const
 
void stream (std::ostream &newos)
 
- Public Member Functions inherited from senf::log::Target
iterator begin () const
 Iterator to beginning of routing table. More...
 
iterator end () const
 Iterator past the end of routing table. More...
 
RoutingEntry const & operator[] (size_type i) const
 Access routing entry. More...
 
size_type size () const
 Number of routing table entries. More...
 
bool empty () const
 true, if routing table empty, false otherwise More...
 
void flush ()
 Clear routing table. More...
 
senf::console::ScopedDirectoryconsoleDir ()
 Get console/config directory. More...
 
 Target (std::string const &name)
 
virtual ~Target ()
 
template<class Stream , class Area , class Level >
void route (action_t action=ACCEPT, int index=-1)
 Add route (static) More...
 
void route (std::string const &stream, std::string const &area="", unsigned level=NONE::value, action_t action=ACCEPT, int index=-1)
 Add route (dynamic) More...
 
template<class Stream , class Area , class Level >
void unroute (action_t action=ACCEPT)
 Remove route (static) More...
 
void unroute (std::string const &stream, std::string const &area="", unsigned level=NONE::value, action_t action=ACCEPT)
 Remove route (dynamic) More...
 
void unroute (int index=-1)
 Remove route (indexed) More...
 

Protected Member Functions

void v_write (time_type timestamp, std::string const &stream, std::string const &area, unsigned level, std::string const &message)
 Called to write out the routing message. More...
 

Structors and default members

 IOStreamTarget (std::string const &name, std::ostream &os)
 

Additional Inherited Members

- Public Types inherited from senf::log::Target
enum  action_t { ACCEPT, REJECT }
 Routing action. More...
 
typedef RIB::const_iterator iterator
 Routing table iterator. More...
 
typedef RIB::size_type size_type
 

Detailed Description

Write log messages to arbitrary std::ostream.

This target will write log messages to an arbitrary std::ostream in the format

<date> [<level>][<area>] <message> 

The area will be omitted if it is senf::log::DefaultArea.

Warning
The class keeps a reference to the passed stream.

Definition at line 41 of file IOStreamTarget.hh.

Constructor & Destructor Documentation

◆ IOStreamTarget()

senf::log::IOStreamTarget::IOStreamTarget ( std::string const &  name,
std::ostream &  os 
)

Member Function Documentation

◆ stream() [1/2]

std::ostream& senf::log::IOStreamTarget::stream ( ) const

◆ stream() [2/2]

void senf::log::IOStreamTarget::stream ( std::ostream &  newos)

◆ v_write()

void senf::log::IOStreamTarget::v_write ( time_type  timestamp,
std::string const &  stream,
std::string const &  area,
unsigned  level,
std::string const &  message 
)
protectedvirtual

Called to write out the routing message.

This member must be defined in the derived class to somehow format and write the log message.

Every log message always possesses a complete set of meta information (stream, area and level).

Note
This member must not block since it may be called from any unknown context. This prohibits simple logging over NFS or many other network protocols.
Parameters
[in]timestamplog message timing information
[in]streammessage stream
[in]areamessage area
[in]levelmessage level
[in]messagethe message string

Implements senf::log::Target.

Definition at line 31 of file IOStreamTarget.cc.


The documentation for this class was generated from the following files: