l4snd::TcpIpAppender Class Reference

Appender to a socket. More...

Inheritance diagram for l4snd::TcpIpAppender:

Inheritance graph
[legend]
Collaboration diagram for l4snd::TcpIpAppender:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 TcpIpAppender (Formatter *formatter, const std::string &host, unsigned port=4448)
 Constructs the appender and tries to open the connection.
 TcpIpAppender (Formatter *formatter, long adr, unsigned port=4448)
 Constructs the appender and tries to open the connection.
virtual ~TcpIpAppender ()
 Destroys the appender.
virtual void append (Logger::Level level, std::string msg, std::string category, LOG4SENDPP_INT64 stamp, const LocationInformation *loginfo, const Logger::DiagnosticInformation *diaginfo)
 Formats a message.
virtual void writeString (const std::string &data)
 Appends a string to the current file.
virtual bool isWorking () const
 Tests if the appender is correctly working.

Static Public Member Functions

static std::string gethostname ()
 Gets the name of this host.

Protected Member Functions

void open ()
 Opens the connection.
void close ()
 Closes the connection.

Classes

struct  Impl
 internal More...


Detailed Description

Appender to a socket.

Definition at line 45 of file tcpip_appender.h.


Constructor & Destructor Documentation

l4snd::TcpIpAppender::TcpIpAppender ( Formatter formatter,
const std::string &  host,
unsigned  port = 4448 
)

Constructs the appender and tries to open the connection.

Parameters:
formatter pointer to foratter
host host name of log host
port destination port. 4448 for default chainsaw configuration

Definition at line 225 of file tcpip_appender.cpp.

References l4snd::TcpIpAppender::Impl::hostdata, LOG4SENDPP_CATCH_ALL, LOG4SENDPP_TRY, l4snd::TcpIpAppender::Impl::net_error, and open().

l4snd::TcpIpAppender::TcpIpAppender ( Formatter formatter,
long  adr,
unsigned  port = 4448 
)

Constructs the appender and tries to open the connection.

Parameters:
formatter pointer to foratter
adr ip address of log host
port destination port. 4448 for default chainsaw configuration

Definition at line 186 of file tcpip_appender.cpp.

References l4snd::TcpIpAppender::Impl::hostdata, LOG4SENDPP_CATCH_ALL, LOG4SENDPP_TRY, l4snd::TcpIpAppender::Impl::net_error, and open().


Member Function Documentation

void l4snd::TcpIpAppender::append ( Logger::Level  level,
std::string  msg,
std::string  category,
LOG4SENDPP_INT64  stamp,
const LocationInformation loginfo,
const Logger::DiagnosticInformation diaginfo 
) [virtual]

Formats a message.

Parameters:
level severty level
msg string to log
category message category
stamp timestamp in milliseconds since 1.1.1970
loginfo pointer to location info or 0
diaginfo pointer to diagnostic info or 0
Returns:
formatted message in one or more lines

Implements l4snd::Appender.

Definition at line 346 of file tcpip_appender.cpp.

References l4snd::Formatter::format(), l4snd::Appender::getFormatter(), isWorking(), LOG4SENDPP_CATCH_ALL, LOG4SENDPP_RETHROW, LOG4SENDPP_TRY, l4snd::TcpIpAppender::Impl::net_error, and writeString().

void l4snd::TcpIpAppender::writeString ( const std::string &  data  )  [virtual]

Appends a string to the current file.

Parameters:
data string with data

Implements l4snd::Appender.

Definition at line 379 of file tcpip_appender.cpp.

References close(), l4snd::TcpIpAppender::Impl::fd_handle, isWorking(), LOG4SENDPP_THROW, l4snd::TcpIpAppender::Impl::net_error, and l4snd::TcpIpAppender::Impl::timeout.

Referenced by append().

bool l4snd::TcpIpAppender::isWorking (  )  const [virtual]

Tests if the appender is correctly working.

Returns:
true if connection is in a sane state

Implements l4snd::Appender.

Definition at line 291 of file tcpip_appender.cpp.

References l4snd::TcpIpAppender::Impl::fd_handle, and l4snd::TcpIpAppender::Impl::net_error.

Referenced by append(), and writeString().

std::string l4snd::TcpIpAppender::gethostname (  )  [static]

Gets the name of this host.

Returns:
hostname

empty string in case of an error and disabled exception handling

Definition at line 203 of file tcpip_appender.cpp.

References LOG4SENDPP_THROW.

Referenced by l4snd::SimpleFormatter::SimpleFormatter(), and l4snd::XmlFormatter::XmlFormatter().


The documentation for this class was generated from the following files:
Generated on Sat Nov 24 14:41:27 2007 for log4sendpp by  doxygen 1.5.3