Interface for logging to network clients. More...
#include <>>
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,...) |
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) |
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. |
Interface for logging to network clients.
The NetwokLogger will pipe all output to clients that subscribed for log messages.
Definition at line 40 of file network_logger.h.
NetworkLogger message types.
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.
fawkes::NetworkLogger::NetworkLogger | ( | FawkesNetworkHub * | hub, | |
LogLevel | log_level = LL_DEBUG | |||
) |
Constructor.
hub | FawkesNetworkHub to use to send and receive messages | |
log_level | minimum 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().
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.
clid | client 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!
clid | client ID of disconnected client |
Implements fawkes::FawkesNetworkHandler.
Definition at line 425 of file network_logger.cpp.
References fawkes::LockList< Type >::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.
msg | message 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::clid(), fawkes::LockList< Type >::lock(), fawkes::FawkesNetworkMessage::msgid(), and fawkes::LockList< Type >::unlock().