The standard MagAOX log manager, used for both process logs and telemetry streams. More...
#include <logManager.hpp>
Public Types | |
typedef _parentT | parentT |
typedef _logFileT | logFileT |
Public Member Functions | |
logManager () | |
Default c'tor. More... | |
~logManager () | |
Destructor. More... | |
void | parent (parentT *p) |
Set the logger parent. More... | |
parentT * | parent () |
Get the logger parent. More... | |
int | writePause (const unsigned long &wp) |
Set a new value of writePause. More... | |
unsigned long | writePause () |
Get the current value of writePause. More... | |
int | logLevel (logPrioT newLev) |
Set a new value of logLevel. More... | |
logPrioT | logLevel () |
Get the current value of logLevel. More... | |
int | logThreadPrio (int newPrio) |
Set a new value of logThreadPrio. More... | |
int | logThreadPrio () |
Get the current value of logThreadPrio. More... | |
bool | logThreadRunning () |
Get status of the log thread running flag. More... | |
int | setupConfig (mx::app::appConfigurator &config) |
Setup an application configurator for the logger section. More... | |
int | loadConfig (mx::app::appConfigurator &config) |
Load the logger section from an application configurator. More... | |
int | logThreadStart () |
Start the logger thread. More... | |
void | logThreadExec () |
Execute the logger thread. More... | |
template<typename logT > | |
void | log (const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT) |
Make a log entry, including a message. More... | |
template<typename logT > | |
void | log (timespecX &ts, const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT) |
Make a log entry, including a message. More... | |
template<typename logT > | |
void | log (logPrioT level=logPrio::LOG_DEFAULT) |
Make a log entry with no message. More... | |
template<typename logT > | |
void | log (timespecX &ts, logPrioT level=logPrio::LOG_DEFAULT) |
Make a log entry with no message. More... | |
Static Public Member Functions | |
static void | _logThreadStart (logManager *l) |
Thread starter, called by logThreadStart on thread construction. Calls logThreadExec. More... | |
template<typename logT > | |
static int | createLog (bufferPtrT &logBuffer, const typename logT::messageT &msg, const logPrioT &level) |
Create a log formatted log entry, filling in a buffer. More... | |
template<typename logT > | |
static int | createLog (bufferPtrT &logBuffer, const timespecX &ts, const typename logT::messageT &msg, const logPrioT &level) |
Create a log formatted log entry, filling in a buffer. More... | |
Public Attributes | |
std::string | m_configSection {"logger"} |
The configuration files section name. Default is logger . More... | |
logPrioT | m_logLevel {logPrio::LOG_INFO} |
The minimum log level to actually record. Logs with level below this are rejected. Default is INFO. Configure with logger.logLevel. More... | |
Protected Attributes | |
parentT * | m_parent {nullptr} |
std::list< bufferPtrT > | m_logQueue |
Log entries are stored here, and writen to the file by the log thread. More... | |
std::thread | m_logThread |
A separate thread for actually writing to the file. More... | |
std::mutex | m_qMutex |
Mutex for accessing the m_logQueue. More... | |
bool | m_logShutdown {false} |
Flag to signal the log thread to shutdown. More... | |
unsigned long | m_writePause {MAGAOX_default_writePause} |
Time, in nanoseconds, to pause between successive batch writes to the file. Default is 1e9. Configure with logger.writePause. More... | |
int | m_logThreadPrio {0} |
bool | m_logThreadRunning {false} |
The standard MagAOX log manager, used for both process logs and telemetry streams.
Manages the formatting and queueing of the log entries.
A log entry is made using one of the standard log types. These are formatted into a binary stream and stored in a std::list. This occurs in the calling thread. The insertion into the list is mutex-ed, so it is safe to make logs from different threads concurrently.
Write-to-disk occurs in a separate thread, which is normally set to the lowest priority so as not to interfere with higher-priority tasks. The log thread cycles through pending log entries in the list, dispatching them to the logFile.
The template parameter logFileT is one of the logFile types, which is used to actually write to disk.
Example:
logFileT | a logFile type with a writeLog method. |
Definition at line 73 of file logManager.hpp.
typedef _logFileT MagAOX::logger::logManager< _parentT, _logFileT >::logFileT |
Definition at line 76 of file logManager.hpp.
typedef _parentT MagAOX::logger::logManager< _parentT, _logFileT >::parentT |
Definition at line 75 of file logManager.hpp.
MagAOX::logger::logManager< parentT, logFileT >::logManager |
Default c'tor.
Definition at line 254 of file logManager.hpp.
MagAOX::logger::logManager< parentT, logFileT >::~logManager |
Destructor.
Definition at line 259 of file logManager.hpp.
|
static |
Thread starter, called by logThreadStart on thread construction. Calls logThreadExec.
[in] | l | a pointer to a logger instance (normally this) |
Definition at line 392 of file logManager.hpp.
|
static |
Create a log formatted log entry, filling in a buffer.
This version has the timestamp provided.
logT | is a log entry type |
[out] | logBuffer | a shared_ptr<logBuffer>, which will be allocated and populated with the log entry |
[in] | ts | the timestamp of this log entry. |
[in] | msg | the message to log (could be of type emptyMessage) |
[in] | level | the level (verbosity) of this log |
Definition at line 516 of file logManager.hpp.
|
static |
Create a log formatted log entry, filling in a buffer.
This is where the timestamp of the log entry is set.
logT | is a log entry type |
[out] | logBuffer | a shared_ptr<logBuffer>, which will be allocated and populated with the log entry |
[in] | msg | the message to log (could be of type emptyMessage) |
[in] | level | the level (verbosity) of this log |
Definition at line 502 of file logManager.hpp.
int MagAOX::logger::logManager< parentT, logFileT >::loadConfig | ( | mx::app::appConfigurator & | config | ) |
Load the logger section from an application configurator.
[in] | config | an application configuration from which to load values |
Definition at line 350 of file logManager.hpp.
void MagAOX::logger::logManager< parentT, logFileT >::log | ( | const typename logT::messageT & | msg, |
logPrioT | level = logPrio::LOG_DEFAULT |
||
) |
Make a log entry, including a message.
logT | is a log entry type |
[in] | msg | the message to log |
[in] | level | [optional] the log level. The default is used if not specified. |
Definition at line 527 of file logManager.hpp.
Referenced by visxCtrl.xapp.VisX::cancel_exposure(), visxCtrl.xapp.VisX::finalize_exposure(), visxCtrl.xapp.VisX::handle_expose(), visxCtrl.xapp.VisX::handle_exptime(), visxCtrl.xapp.VisX::handle_gain(), audibleAlerts.core.AudibleAlerts::handle_personality_switch(), audibleAlerts.core.AudibleAlerts::handle_soundboard_switch(), audibleAlerts.core.AudibleAlerts::handle_speech_request(), audibleAlerts.core.AudibleAlerts::handle_speech_text(), visxCtrl.xapp.VisX::handle_temp_ccd(), dbIngest.dbIngest::ingest_line(), dbIngest.dbIngest::launch_followers(), audibleAlerts.core.AudibleAlerts::loop(), visxCtrl.xapp.VisX::loop(), audibleAlerts.core.AudibleAlerts::preprocess(), MagAOX::app::sshDigger::processAutoSSHLog(), MagAOX::app::xindiserver::processISLog(), MagAOX::app::sshDigger::processSSHLog(), audibleAlerts.core.AudibleAlerts::reaction_handler(), dbIngest.dbIngest::rescan_files(), corAlign.corAlign::setup(), efcControl.efcControl::setup(), visxCtrl.xapp.VisX::setup(), and visxCtrl.xapp.VisX::subscribe_to_other_devices().
void MagAOX::logger::logManager< parentT, logFileT >::log | ( | logPrioT | level = logPrio::LOG_DEFAULT | ) |
Make a log entry with no message.
logT | is a log entry type |
[in] | level | [optional] the log level. The default is used if not specified. |
Definition at line 571 of file logManager.hpp.
Referenced by visxCtrl.xapp.VisX::cancel_exposure(), visxCtrl.xapp.VisX::finalize_exposure(), visxCtrl.xapp.VisX::handle_expose(), visxCtrl.xapp.VisX::handle_exptime(), visxCtrl.xapp.VisX::handle_gain(), audibleAlerts.core.AudibleAlerts::handle_personality_switch(), audibleAlerts.core.AudibleAlerts::handle_soundboard_switch(), audibleAlerts.core.AudibleAlerts::handle_speech_request(), audibleAlerts.core.AudibleAlerts::handle_speech_text(), visxCtrl.xapp.VisX::handle_temp_ccd(), dbIngest.dbIngest::ingest_line(), dbIngest.dbIngest::launch_followers(), audibleAlerts.core.AudibleAlerts::loop(), visxCtrl.xapp.VisX::loop(), audibleAlerts.core.AudibleAlerts::preprocess(), audibleAlerts.core.AudibleAlerts::reaction_handler(), dbIngest.dbIngest::rescan_files(), corAlign.corAlign::setup(), efcControl.efcControl::setup(), visxCtrl.xapp.VisX::setup(), and visxCtrl.xapp.VisX::subscribe_to_other_devices().
void MagAOX::logger::logManager< parentT, logFileT >::log | ( | timespecX & | ts, |
const typename logT::messageT & | msg, | ||
logPrioT | level = logPrio::LOG_DEFAULT |
||
) |
Make a log entry, including a message.
logT | is a log entry type |
[in] | ts | the timestamp of the log entry |
[in] | msg | the message to log |
[in] | level | [optional] the log level. The default is used if not specified. |
Definition at line 549 of file logManager.hpp.
Referenced by visxCtrl.xapp.VisX::cancel_exposure(), visxCtrl.xapp.VisX::finalize_exposure(), visxCtrl.xapp.VisX::handle_expose(), visxCtrl.xapp.VisX::handle_exptime(), visxCtrl.xapp.VisX::handle_gain(), audibleAlerts.core.AudibleAlerts::handle_personality_switch(), audibleAlerts.core.AudibleAlerts::handle_soundboard_switch(), audibleAlerts.core.AudibleAlerts::handle_speech_request(), audibleAlerts.core.AudibleAlerts::handle_speech_text(), visxCtrl.xapp.VisX::handle_temp_ccd(), dbIngest.dbIngest::ingest_line(), dbIngest.dbIngest::launch_followers(), audibleAlerts.core.AudibleAlerts::loop(), visxCtrl.xapp.VisX::loop(), audibleAlerts.core.AudibleAlerts::preprocess(), audibleAlerts.core.AudibleAlerts::reaction_handler(), dbIngest.dbIngest::rescan_files(), corAlign.corAlign::setup(), efcControl.efcControl::setup(), visxCtrl.xapp.VisX::setup(), and visxCtrl.xapp.VisX::subscribe_to_other_devices().
void MagAOX::logger::logManager< parentT, logFileT >::log | ( | timespecX & | ts, |
logPrioT | level = logPrio::LOG_DEFAULT |
||
) |
Make a log entry with no message.
logT | is a log entry type |
[in] | ts | the timestamp of the log entry |
[in] | level | [optional] the log level. The default is used if not specified. |
Definition at line 578 of file logManager.hpp.
Referenced by visxCtrl.xapp.VisX::cancel_exposure(), visxCtrl.xapp.VisX::finalize_exposure(), visxCtrl.xapp.VisX::handle_expose(), visxCtrl.xapp.VisX::handle_exptime(), visxCtrl.xapp.VisX::handle_gain(), audibleAlerts.core.AudibleAlerts::handle_personality_switch(), audibleAlerts.core.AudibleAlerts::handle_soundboard_switch(), audibleAlerts.core.AudibleAlerts::handle_speech_request(), audibleAlerts.core.AudibleAlerts::handle_speech_text(), visxCtrl.xapp.VisX::handle_temp_ccd(), dbIngest.dbIngest::ingest_line(), dbIngest.dbIngest::launch_followers(), audibleAlerts.core.AudibleAlerts::loop(), visxCtrl.xapp.VisX::loop(), audibleAlerts.core.AudibleAlerts::preprocess(), audibleAlerts.core.AudibleAlerts::reaction_handler(), dbIngest.dbIngest::rescan_files(), corAlign.corAlign::setup(), efcControl.efcControl::setup(), visxCtrl.xapp.VisX::setup(), and visxCtrl.xapp.VisX::subscribe_to_other_devices().
logPrioT MagAOX::logger::logManager< parentT, logFileT >::logLevel |
Get the current value of logLevel.
Definition at line 309 of file logManager.hpp.
int MagAOX::logger::logManager< parentT, logFileT >::logLevel | ( | logPrioT | newLev | ) |
Set a new value of logLevel.
Updates m_logLevel with new value. Will return an error and take no actions if the argument is outside the range of the logLevels enum.
[in] | newLev | the new value of logLevel |
Definition at line 299 of file logManager.hpp.
Referenced by MagAOX::app::sshDigger::execTunnel(), and MagAOX::app::xindiserver::forkIndiserver().
void MagAOX::logger::logManager< parentT, logFileT >::logThreadExec |
Execute the logger thread.
fsyncgate
impacts us Definition at line 438 of file logManager.hpp.
Referenced by MagAOX::logger::logManager< _parentT, _logFileT >::_logThreadStart().
int MagAOX::logger::logManager< parentT, logFileT >::logThreadPrio |
Get the current value of logThreadPrio.
Definition at line 325 of file logManager.hpp.
int MagAOX::logger::logManager< parentT, logFileT >::logThreadPrio | ( | int | newPrio | ) |
Set a new value of logThreadPrio.
Updates m_logThreadPrio with new value. If the argument is < 0, this sets m_logThreadPrio to 0. Will not set > 98, and returns -1 with no changes in this case.
[in] | newPrio | the new value of logThreadPrio |
Definition at line 315 of file logManager.hpp.
bool MagAOX::logger::logManager< parentT, logFileT >::logThreadRunning |
Get status of the log thread running flag.
Definition at line 331 of file logManager.hpp.
int MagAOX::logger::logManager< parentT, logFileT >::logThreadStart |
Start the logger thread.
Definition at line 398 of file logManager.hpp.
parentT * MagAOX::logger::logManager< parentT, logFileT >::parent |
Get the logger parent.
Returns a point to the parent object.
Definition at line 277 of file logManager.hpp.
void MagAOX::logger::logManager< parentT, logFileT >::parent | ( | parentT * | p | ) |
Set the logger parent.
The parent is used for interactive presentation of log messages
[in] | p | pointer to the parent object |
Definition at line 271 of file logManager.hpp.
int MagAOX::logger::logManager< parentT, logFileT >::setupConfig | ( | mx::app::appConfigurator & | config | ) |
Setup an application configurator for the logger section.
[in] | config | an application configuration to setup |
Definition at line 337 of file logManager.hpp.
unsigned long MagAOX::logger::logManager< parentT, logFileT >::writePause |
Get the current value of writePause.
Definition at line 293 of file logManager.hpp.
int MagAOX::logger::logManager< parentT, logFileT >::writePause | ( | const unsigned long & | wp | ) |
Set a new value of writePause.
Updates m_writePause with new value.
[in] | wp | the new value of writePause |
Definition at line 283 of file logManager.hpp.
std::string MagAOX::logger::logManager< _parentT, _logFileT >::m_configSection {"logger"} |
The configuration files section name. Default is logger
.
Definition at line 84 of file logManager.hpp.
logPrioT MagAOX::logger::logManager< _parentT, _logFileT >::m_logLevel {logPrio::LOG_INFO} |
The minimum log level to actually record. Logs with level below this are rejected. Default is INFO. Configure with logger.logLevel.
Definition at line 97 of file logManager.hpp.
|
protected |
Log entries are stored here, and writen to the file by the log thread.
Definition at line 87 of file logManager.hpp.
|
protected |
Flag to signal the log thread to shutdown.
Definition at line 92 of file logManager.hpp.
|
protected |
A separate thread for actually writing to the file.
Definition at line 89 of file logManager.hpp.
|
protected |
Definition at line 100 of file logManager.hpp.
|
protected |
Definition at line 102 of file logManager.hpp.
|
protected |
Definition at line 79 of file logManager.hpp.
|
protected |
Mutex for accessing the m_logQueue.
Definition at line 90 of file logManager.hpp.
|
protected |
Time, in nanoseconds, to pause between successive batch writes to the file. Default is 1e9. Configure with logger.writePause.
Definition at line 94 of file logManager.hpp.