Fawkes API  Fawkes Development Version
fawkes::NetworkLogger Class Reference

Interface for logging to network clients. More...

#include <>>

Inheritance diagram for fawkes::NetworkLogger:

List of all members.

Classes

struct  network_logger_header_t
 Network logging message header. More...

Public Types

enum  network_logger_msgtype_t { MSGTYPE_SUBSCRIBE = 1, MSGTYPE_UNSUBSCRIBE = 2, MSGTYPE_LOGMESSAGE = 3 }
 NetworkLogger message types. More...

Public Member Functions

 NetworkLogger (FawkesNetworkHub *hub, LogLevel log_level=LL_DEBUG)
 Constructor.
virtual ~NetworkLogger ()
 Destructor.
virtual void log_debug (const char *component, const char *format,...)
 Log debug message.
virtual void log_info (const char *component, const char *format,...)
 Log informational message.
virtual void log_warn (const char *component, const char *format,...)
 Log warning message.
virtual void log_error (const char *component, const char *format,...)
 Log error message.
virtual void log_debug (const char *component, Exception &e)
 Log debug exception.
virtual void log_info (const char *component, Exception &e)
 Log informational exception.
virtual void log_warn (const char *component, Exception &e)
 Log warning exception.
virtual void log_error (const char *component, Exception &e)
 Log error exception.
virtual void vlog_debug (const char *component, const char *format, va_list va)
 Log debug message.
virtual void vlog_info (const char *component, const char *format, va_list va)
 Log informational message.
virtual void vlog_warn (const char *component, const char *format, va_list va)
 Log warning message.
virtual void vlog_error (const char *component, const char *format, va_list va)
 Log error message.
virtual void tlog_debug (struct timeval *t, const char *component, const char *format,...)
 Log debug message for specific time.
virtual void tlog_info (struct timeval *t, const char *component, const char *format,...)
 Log informational message for specific time.
virtual void tlog_warn (struct timeval *t, const char *component, const char *format,...)
 Log warning message for specific time.
virtual void tlog_error (struct timeval *t, const char *component, const char *format,...)
 Log error message for specific time.
virtual void tlog_debug (struct timeval *t, const char *component, Exception &e)
 Log debug exception for specific time.
virtual void tlog_info (struct timeval *t, const char *component, Exception &e)
 Log informational exception for specific time.
virtual void tlog_warn (struct timeval *t, const char *component, Exception &e)
 Log warning exception for specific time.
virtual void tlog_error (struct timeval *t, const char *component, Exception &e)
 Log error exception for specific time.
virtual void vtlog_debug (struct timeval *t, const char *component, const char *format, va_list va)
 Log debug message for specific time.
virtual void vtlog_info (struct timeval *t, const char *component, const char *format, va_list va)
 Log informational message for specific time.
virtual void vtlog_warn (struct timeval *t, const char *component, const char *format, va_list va)
 Log warning message for specific time.
virtual void vtlog_error (struct timeval *t, const char *component, const char *format, va_list va)
 Log error message for specific time.
virtual void handle_network_message (FawkesNetworkMessage *msg)
 Called for incoming messages that are addressed to the correct component ID.
virtual void client_connected (unsigned int clid)
 Called when a new client connected.
virtual void client_disconnected (unsigned int clid)
 Called when a client disconnected.

Detailed Description

Interface for logging to network clients.

The NetwokLogger will pipe all output to clients that subscribed for log messages.

Author:
Tim Niemueller

Member Enumeration Documentation

NetworkLogger message types.

Enumerator:
MSGTYPE_SUBSCRIBE 

Subscribe for logging messages.

MSGTYPE_UNSUBSCRIBE 

Unsubscribe from receiving logging messages.

MSGTYPE_LOGMESSAGE 

Log message.

Definition at line 87 of file network_logger.h.


Constructor & Destructor Documentation

fawkes::NetworkLogger::NetworkLogger ( FawkesNetworkHub hub,
LogLevel  log_level = LL_DEBUG 
)

Constructor.

Parameters:
hubFawkesNetworkHub to use to send and receive messages
log_levelminimum level to log

Definition at line 57 of file network_logger.cpp.

References fawkes::FawkesNetworkHub::add_handler().

fawkes::NetworkLogger::~NetworkLogger ( ) [virtual]

Destructor.

Definition at line 68 of file network_logger.cpp.

References fawkes::FawkesNetworkHub::remove_handler().


Member Function Documentation

void fawkes::NetworkLogger::client_connected ( unsigned int  clid) [virtual]

Called when a new client connected.

If any actions need to be taken on your side this is the place to do it.

Parameters:
clidclient ID of new client

Implements fawkes::FawkesNetworkHandler.

Definition at line 419 of file network_logger.cpp.

void fawkes::NetworkLogger::client_disconnected ( unsigned int  clid) [virtual]

Called when a client disconnected.

If any actions need to be taken on your side this is the place to do it. Note that you cannot send any further messages to this client!

Parameters:
clidclient ID of disconnected client

Implements fawkes::FawkesNetworkHandler.

Definition at line 425 of file network_logger.cpp.

References fawkes::LockList::remove_locked().

void fawkes::NetworkLogger::handle_network_message ( FawkesNetworkMessage msg) [virtual]

Called for incoming messages that are addressed to the correct component ID.

Note that this message should be processed really really fast! A good idea is to enqueue the message in an inbound queue (remember to ref() it!) and then process it in the next run of loop() or wakeup a processing thread.

Parameters:
msgmessage to handle. If you want to keep this message you have to ref() it! It is guaranteed that the message will not be erased during the handleNetworkMessage() run, but afterwards no guarantee is made. So if you want to store the message internally for example for later processing you have to reference the message.

Implements fawkes::FawkesNetworkHandler.

Definition at line 406 of file network_logger.cpp.

References fawkes::FawkesNetworkMessage::cid(), fawkes::FawkesNetworkMessage::msgid(), MSGTYPE_SUBSCRIBE, fawkes::LockList::lock(), fawkes::FawkesNetworkMessage::clid(), and fawkes::LockList::unlock().

void fawkes::NetworkLogger::log_debug ( const char *  component,
const char *  format,
  ... 
) [virtual]

Log debug message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 177 of file network_logger.cpp.

References vlog_debug().

void fawkes::NetworkLogger::log_debug ( const char *  component,
Exception e 
) [virtual]

Log debug exception.

Parameters:
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 217 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_DEBUG, fawkes::LockList::lock(), fawkes::Exception::begin(), fawkes::Exception::end(), and fawkes::LockList::unlock().

void fawkes::NetworkLogger::log_error ( const char *  component,
const char *  format,
  ... 
) [virtual]

Log error message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 207 of file network_logger.cpp.

References vlog_error().

void fawkes::NetworkLogger::log_error ( const char *  component,
Exception e 
) [virtual]

Log error exception.

Parameters:
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 255 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_ERROR, fawkes::LockList::lock(), fawkes::Exception::begin(), fawkes::Exception::end(), and fawkes::LockList::unlock().

void fawkes::NetworkLogger::log_info ( const char *  component,
const char *  format,
  ... 
) [virtual]

Log informational message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 187 of file network_logger.cpp.

References vlog_info().

void fawkes::NetworkLogger::log_info ( const char *  component,
Exception e 
) [virtual]

Log informational exception.

Parameters:
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 229 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_INFO, fawkes::LockList::lock(), fawkes::Exception::begin(), fawkes::Exception::end(), and fawkes::LockList::unlock().

void fawkes::NetworkLogger::log_warn ( const char *  component,
const char *  format,
  ... 
) [virtual]

Log warning message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 197 of file network_logger.cpp.

References vlog_warn().

void fawkes::NetworkLogger::log_warn ( const char *  component,
Exception e 
) [virtual]

Log warning exception.

Parameters:
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 242 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_WARN, fawkes::LockList::lock(), fawkes::Exception::begin(), fawkes::Exception::end(), and fawkes::LockList::unlock().

void fawkes::NetworkLogger::tlog_debug ( struct timeval *  t,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log debug message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 315 of file network_logger.cpp.

References vtlog_debug().

void fawkes::NetworkLogger::tlog_debug ( struct timeval *  t,
const char *  component,
Exception e 
) [virtual]

Log debug exception for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 355 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_DEBUG, fawkes::LockList::lock(), fawkes::Exception::begin(), fawkes::Exception::end(), and fawkes::LockList::unlock().

void fawkes::NetworkLogger::tlog_error ( struct timeval *  t,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log error message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 345 of file network_logger.cpp.

References vtlog_error().

void fawkes::NetworkLogger::tlog_error ( struct timeval *  t,
const char *  component,
Exception e 
) [virtual]

Log error exception for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 393 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_ERROR, fawkes::LockList::lock(), fawkes::Exception::begin(), fawkes::Exception::end(), and fawkes::LockList::unlock().

void fawkes::NetworkLogger::tlog_info ( struct timeval *  t,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log informational message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 325 of file network_logger.cpp.

References vtlog_info().

void fawkes::NetworkLogger::tlog_info ( struct timeval *  t,
const char *  component,
Exception e 
) [virtual]

Log informational exception for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 367 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_INFO, fawkes::LockList::lock(), fawkes::Exception::begin(), fawkes::Exception::end(), and fawkes::LockList::unlock().

void fawkes::NetworkLogger::tlog_warn ( struct timeval *  t,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log warning message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 335 of file network_logger.cpp.

References vtlog_warn().

void fawkes::NetworkLogger::tlog_warn ( struct timeval *  t,
const char *  component,
Exception e 
) [virtual]

Log warning exception for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 380 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_WARN, fawkes::LockList::lock(), fawkes::Exception::begin(), fawkes::Exception::end(), and fawkes::LockList::unlock().

void fawkes::NetworkLogger::vlog_debug ( const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log debug message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 133 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_DEBUG, fawkes::LockList::lock(), and fawkes::LockList::unlock().

Referenced by log_debug().

void fawkes::NetworkLogger::vlog_error ( const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log error message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 166 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_ERROR, fawkes::LockList::lock(), and fawkes::LockList::unlock().

Referenced by log_error().

void fawkes::NetworkLogger::vlog_info ( const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log informational message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 144 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_INFO, fawkes::LockList::lock(), and fawkes::LockList::unlock().

Referenced by log_info().

void fawkes::NetworkLogger::vlog_warn ( const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log warning message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 155 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_WARN, fawkes::LockList::lock(), and fawkes::LockList::unlock().

Referenced by log_warn().

void fawkes::NetworkLogger::vtlog_debug ( struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log debug message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 270 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_DEBUG, fawkes::LockList::lock(), and fawkes::LockList::unlock().

Referenced by tlog_debug().

void fawkes::NetworkLogger::vtlog_error ( struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log error message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 304 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_ERROR, fawkes::LockList::lock(), and fawkes::LockList::unlock().

Referenced by tlog_error().

void fawkes::NetworkLogger::vtlog_info ( struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log informational message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 282 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_INFO, fawkes::LockList::lock(), and fawkes::LockList::unlock().

Referenced by tlog_info().

void fawkes::NetworkLogger::vtlog_warn ( struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log warning message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 293 of file network_logger.cpp.

References fawkes::Logger::log_level, fawkes::Logger::LL_WARN, fawkes::LockList::lock(), and fawkes::LockList::unlock().

Referenced by tlog_warn().


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