Fawkes API  Fawkes Development Version
fawkes::NetworkLogger Class Reference

#include <>>

Inheritance diagram for fawkes::NetworkLogger:

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 Types inherited from fawkes::Logger
enum  LogLevel {
  LL_DEBUG = 0, LL_INFO = 1, LL_WARN = 2, LL_ERROR = 4,
  LL_NONE = 8
}
 Log level. More...
 

Public Member Functions

 NetworkLogger (FawkesNetworkHub *hub, LogLevel log_level=LL_DEBUG)
 Constructor. More...
 
virtual ~NetworkLogger ()
 Destructor. More...
 
virtual void log_debug (const char *component, const char *format,...)
 
virtual void log_info (const char *component, const char *format,...)
 
virtual void log_warn (const char *component, const char *format,...)
 
virtual void log_error (const char *component, const char *format,...)
 
virtual void log_debug (const char *component, Exception &e)
 
virtual void log_info (const char *component, Exception &e)
 
virtual void log_warn (const char *component, Exception &e)
 
virtual void log_error (const char *component, Exception &e)
 
virtual void vlog_debug (const char *component, const char *format, va_list va)
 
virtual void vlog_info (const char *component, const char *format, va_list va)
 
virtual void vlog_warn (const char *component, const char *format, va_list va)
 
virtual void vlog_error (const char *component, const char *format, va_list va)
 
virtual void tlog_debug (struct timeval *t, const char *component, const char *format,...)
 
virtual void tlog_info (struct timeval *t, const char *component, const char *format,...)
 
virtual void tlog_warn (struct timeval *t, const char *component, const char *format,...)
 
virtual void tlog_error (struct timeval *t, const char *component, const char *format,...)
 
virtual void tlog_debug (struct timeval *t, const char *component, Exception &e)
 
virtual void tlog_info (struct timeval *t, const char *component, Exception &e)
 
virtual void tlog_warn (struct timeval *t, const char *component, Exception &e)
 
virtual void tlog_error (struct timeval *t, const char *component, Exception &e)
 
virtual void vtlog_debug (struct timeval *t, const char *component, const char *format, va_list va)
 
virtual void vtlog_info (struct timeval *t, const char *component, const char *format, va_list va)
 
virtual void vtlog_warn (struct timeval *t, const char *component, const char *format, va_list va)
 
virtual void vtlog_error (struct timeval *t, const char *component, const char *format, va_list va)
 
virtual void handle_network_message (FawkesNetworkMessage *msg)
 
virtual void client_connected (unsigned int clid)
 
virtual void client_disconnected (unsigned int clid)
 
- Public Member Functions inherited from fawkes::Logger
 Logger (LogLevel log_level=LL_DEBUG)
 Constructor. More...
 
virtual ~Logger ()
 Virtual empty destructor. More...
 
virtual void set_loglevel (LogLevel level)
 Sets the log level. More...
 
virtual LogLevel loglevel ()
 Get log level. More...
 
virtual void log (LogLevel level, const char *component, const char *format,...)
 Log message of given log level. More...
 
virtual void log (LogLevel level, const char *component, Exception &e)
 Log exception for given log level. More...
 
virtual void vlog (LogLevel level, const char *component, const char *format, va_list va)
 Log message for given log level. More...
 
virtual void tlog (LogLevel level, struct timeval *t, const char *component, const char *format,...)
 Log message of given log level and time. More...
 
virtual void tlog (LogLevel level, struct timeval *t, const char *component, Exception &e)
 Log exception for given log level. More...
 
virtual void vtlog (LogLevel level, struct timeval *t, const char *component, const char *format, va_list va)
 Log message for given log level and time. More...
 
- Public Member Functions inherited from fawkes::FawkesNetworkHandler
 FawkesNetworkHandler (unsigned short int id)
 Constructor. More...
 
virtual ~FawkesNetworkHandler ()
 Destructor. More...
 
unsigned short int id () const
 Get the component ID for this handler. More...
 

Additional Inherited Members

- Protected Attributes inherited from fawkes::Logger
LogLevel log_level
 Minimum log level. More...
 

Detailed Description

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

Author
Tim Niemueller

Definition at line 44 of file network_logger.h.

Member Enumeration Documentation

◆ network_logger_msgtype_t

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

◆ NetworkLogger()

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 59 of file network_logger.cpp.

◆ ~NetworkLogger()

fawkes::NetworkLogger::~NetworkLogger ( )
virtual

Destructor.

Definition at line 68 of file network_logger.cpp.

References MSGTYPE_LOGMESSAGE, and fawkes::FawkesNetworkHub::send().

Member Function Documentation

◆ client_connected()

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 391 of file network_logger.cpp.

References fawkes::LockList< Type >::remove_locked().

◆ client_disconnected()

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 396 of file network_logger.cpp.

◆ handle_network_message()

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 379 of file network_logger.cpp.

◆ log_debug() [1/2]

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 171 of file network_logger.cpp.

◆ log_debug() [2/2]

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 207 of file network_logger.cpp.

References fawkes::Logger::LL_DEBUG.

◆ log_error() [1/2]

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 198 of file network_logger.cpp.

◆ log_error() [2/2]

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 243 of file network_logger.cpp.

References fawkes::Logger::LL_ERROR.

◆ log_info() [1/2]

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 180 of file network_logger.cpp.

◆ log_info() [2/2]

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 219 of file network_logger.cpp.

References fawkes::Logger::LL_INFO.

◆ log_warn() [1/2]

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 189 of file network_logger.cpp.

◆ log_warn() [2/2]

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 231 of file network_logger.cpp.

References fawkes::Logger::LL_WARN.

◆ tlog_debug() [1/2]

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 295 of file network_logger.cpp.

◆ tlog_debug() [2/2]

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 331 of file network_logger.cpp.

References fawkes::Logger::LL_DEBUG.

◆ tlog_error() [1/2]

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 322 of file network_logger.cpp.

◆ tlog_error() [2/2]

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 367 of file network_logger.cpp.

References fawkes::Logger::LL_ERROR.

◆ tlog_info() [1/2]

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 304 of file network_logger.cpp.

◆ tlog_info() [2/2]

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 343 of file network_logger.cpp.

References fawkes::Logger::LL_INFO.

◆ tlog_warn() [1/2]

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 313 of file network_logger.cpp.

◆ tlog_warn() [2/2]

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 355 of file network_logger.cpp.

References fawkes::Logger::LL_WARN.

◆ vlog_debug()

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 131 of file network_logger.cpp.

◆ vlog_error()

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 161 of file network_logger.cpp.

◆ vlog_info()

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 141 of file network_logger.cpp.

◆ vlog_warn()

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 151 of file network_logger.cpp.

◆ vtlog_debug()

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 255 of file network_logger.cpp.

◆ vtlog_error()

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 285 of file network_logger.cpp.

◆ vtlog_info()

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 265 of file network_logger.cpp.

◆ vtlog_warn()

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 275 of file network_logger.cpp.


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