nidas  v1.2-1520
Modules | Files | Classes | Macros | Functions
Logging

Three main classes comprise the nidas::util logging facility: More...

Modules

 Integer Logger Levels
 Define constants equal to the syslog levels, so we can redefine the syslog symbols.
 
 Logging Macros
 These macros specify a log point in the code from which the given message can be logged with the given log level.
 

Files

file  Logger.h
 Header file for the nidas::util logging facility.
 

Classes

class  nidas::util::LogContext
 The LogContext is created at a point in the application code and filled in with details about that log point, such as the file and line number, and the function name of the containing function, and the log level of that log point, such as LOGGER_DEBUG or LOGGER_ERROR. More...
 
class  nidas::util::LogConfig
 A configuration to enable or disable a matching set of log points. More...
 
class  nidas::util::LogScheme
 A LogScheme is a vector of LogConfig's and the vector of fields to show in log messages. More...
 
class  nidas::util::LogMessage
 A class for formatting and streaming a log message. More...
 
class  nidas::util::Logger
 Simple logging class, based on UNIX syslog interface. More...
 

Macros

#define LOG_CONTEXT(LEVEL)   nidas::util::LEVEL, __FILE__, __PRETTY_FUNCTION__, __LINE__
 
#define LOG_STATIC_CONTEXT(LEVEL)   nidas::util::LEVEL, __FILE__, "file_static_scope", __LINE__
 Expand to LogContext tuple outside function scope. More...
 
#define LOG_EMERG   LOG_CONTEXT(LOGGER_EMERG)
 
#define LOG_ALERT   LOG_CONTEXT(LOGGER_ALERT)
 
#define LOG_CRIT   LOG_CONTEXT(LOGGER_CRIT)
 
#define LOG_ERR   LOG_CONTEXT(LOGGER_ERR)
 
#define LOG_WARNING   LOG_CONTEXT(LOGGER_WARNING)
 
#define LOG_NOTICE   LOG_CONTEXT(LOGGER_NOTICE)
 
#define LOG_INFO   LOG_CONTEXT(LOGGER_INFO)
 
#define LOG_DEBUG   LOG_CONTEXT(LOGGER_DEBUG)
 
#define LOG_VERBOSE   LOG_CONTEXT(LOGGER_VERBOSE)
 
#define LOGGER_LOGPOINT(LEVEL, TAGS, MSG)
 This macro creates a static LogContext instance that is not in thread-local storage and therefore is not thread-safe. More...
 

Functions

int nidas::util::stringToLogLevel (const std::string &slevel)
 Convert the name of a log level to its integer value. More...
 
string nidas::util::logLevelToString (int)
 Convert an integral log level to a string name. More...
 
LogMessage & nidas::util::endlog (LogMessage &logmsg)
 LogMessage manipulator which logs the current message buffer, if any, and then clears the message. More...
 
LogMessage & nidas::util::operator<< (LogMessage &logmsg, LogMessage &(*op)(LogMessage &))
 Template to call LogMessage manipulators like endlog when streamed to a LogMessage. More...
 
template<typename T >
LogMessage & nidas::util::LogMessage::operator<< (const T &t)
 Everything streamed to a LogMessage is passed on to the underlying ostringstream, including ostream manipulators. More...
 
void nidas::util::LogContext::log (const std::string &msg) const
 Convenience method which writes the given message to the current Logger instance, passing this object as the LogContext instance. More...
 
LogMessage nidas::util::LogContext::log () const
 Return a LogMessage associated with this LogContext, so the message will be logged through this context when the LogMessage goes out of scope. More...
 
template<typename T >
nidas::util::LogScheme::getParameterT (const std::string &name, const T &dvalue=T())
 Lookup a parameter with name name in a LogScheme and convert the value to the type of the dvalue parameter. More...
 
const int nidas::util::LOGGER_EMERGENCY = LOG_EMERG
 
const int nidas::util::LOGGER_ALERT = LOG_ALERT
 
const int nidas::util::LOGGER_CRIT = LOG_CRIT
 
const int nidas::util::LOGGER_CRITICAL = LOG_CRIT
 
const int nidas::util::LOGGER_ERROR = LOG_ERR
 
const int nidas::util::LOGGER_ERR = LOG_ERR
 
const int nidas::util::LOGGER_PROBLEM = LOG_ERR
 
const int nidas::util::LOGGER_WARNING = LOG_WARNING
 
const int nidas::util::LOGGER_NOTICE = LOG_NOTICE
 
const int nidas::util::LOGGER_INFO = LOG_INFO
 
const int nidas::util::LOGGER_DEBUG = LOG_DEBUG
 
const int nidas::util::LOGGER_VERBOSE = LOG_DEBUG+1
 
const int nidas::util::LOGGER_NONE = LOG_EMERG-1
 
#define ALOG(MSG)   LOGGER_LOGPOINT(LOGGER_ALERT,"",MSG)
 
#define CLOG(MSG)   LOGGER_LOGPOINT(LOGGER_CRITICAL,"",MSG)
 
#define PLOG(MSG)   LOGGER_LOGPOINT(LOGGER_ERR,"",MSG)
 
#define WLOG(MSG)   LOGGER_LOGPOINT(LOGGER_WARNING,"",MSG)
 
#define NLOG(MSG)   LOGGER_LOGPOINT(LOGGER_NOTICE,"",MSG)
 
#define ILOG(MSG)   LOGGER_LOGPOINT(LOGGER_INFO,"",MSG)
 
#define DLOG(MSG)   LOGGER_LOGPOINT(LOGGER_DEBUG,"",MSG)
 
#define VLOG(MSG)   LOGGER_LOGPOINT(LOGGER_VERBOSE,"",MSG)
 
#define ELOGT(TAGS, MSG)   LOGGER_LOGPOINT(LOGGER_EMERG,TAGS,MSG)
 
#define ALOGT(TAGS, MSG)   LOGGER_LOGPOINT(LOGGER_ALERT,TAGS,MSG)
 
#define CLOGT(TAGS, MSG)   LOGGER_LOGPOINT(LOGGER_CRITICAL,TAGS,MSG)
 
#define PLOGT(TAGS, MSG)   LOGGER_LOGPOINT(LOGGER_ERR,TAGS,MSG)
 
#define WLOGT(TAGS, MSG)   LOGGER_LOGPOINT(LOGGER_WARNING,TAGS,MSG)
 
#define NLOGT(TAGS, MSG)   LOGGER_LOGPOINT(LOGGER_NOTICE,TAGS,MSG)
 
#define ILOGT(TAGS, MSG)   LOGGER_LOGPOINT(LOGGER_INFO,TAGS,MSG)
 
#define DLOGT(TAGS, MSG)   LOGGER_LOGPOINT(LOGGER_DEBUG,TAGS,MSG)
 
#define VLOGT(TAGS, MSG)   LOGGER_LOGPOINT(LOGGER_VERBOSE,TAGS,MSG)
 

Detailed Description

Three main classes comprise the nidas::util logging facility:

- nidas::util::LogContext
- nidas::util::Logger
- nidas::util::LogConfig

The intended use of this interface is through the Logging Macros. These macros automatically instantiate a LogContext and control the formatting and sending of the log message according to the current logging configuration. The advantage of the macros is that they are less verbose and there is no overhead formatting the message parameters if the log message is not currently enabled. However, the original form of calling the Logger::log() method directly still works. That form could be more natural in some cases. It is equivalent to the macros except the log message call cannot suppressed: the message itself is suppressed within the log() method by checking the LogContext against the current configuration. The syslog macros like LOG_EMERG are redefined to be a comma-separated list of the LogContext parameters, so those parameters are passed into the log() call. In other words, consider original logging code that looks like this:

"~DSMEngine %s: %s",output->getName().c_str(),e.what());

LOG_INFO is expanded to this:

nidas::util::LOGGER_INFO, __FILE__, __PRETTY_FUNCTION__, __LINE__

So the log() call receives all of the context information it needs to first of all compile a more complete log message, and second to determine if the message has been enabled.

The log() call above could be rewritten using a macro as follows:

ILOG(("~DSMEngine %s: %s",output->getName().c_str(),e.what()));

or alternatively with ostream operators:

ILOG(("~DSMEngine ") << output->getName() << ": " << e.what());

LogConfig objects can be created to configure the set of log points which will be active. See Logging Configuration Schemes.

NIDAS can configure the available logging schemes and the current scheme through the XML config file. Below is an excerpt from within the <project> element. The log scheme is set with the <logger> element.

Todo:
A nice enhancement someday would be to set the log scheme name from the dsm command-line.
<logger scheme='everything' />
<logscheme name='everything'>
<showfields>all</showfields>
<logconfig level='debug'/>
<logconfig filematch='nidas'/>
</logscheme>
<logscheme name='everything-but-utils'>
<showfields>all</showfields>
<logconfig level='debug'/>
<logconfig filematch='util' activate='false'/>
</logscheme>
<logscheme name='nothing'>
</logscheme>
<logscheme name='info'>
<logconfig level='info'/>
</logscheme>
<logscheme name='sampledebug'>
<logconfig level='debug'/>
<logconfig tagmatch='samples'/>
</logscheme>
<logscheme name='iss-debug'>
<showfields>level,time,function,message</showfields>
<logconfig filematch='dynld/iss'/>
</logscheme>
<logscheme name='tilt-sensor-debug'>
<logconfig filematch='dynld/iss'/>
<logconfig filematch='dynld/psql'/>
<logconfig filematch='nidas/core'/>
</logscheme>

Macro Definition Documentation

#define ALOG (   MSG)    LOGGER_LOGPOINT(LOGGER_ALERT,"",MSG)
#define ALOGT (   TAGS,
  MSG 
)    LOGGER_LOGPOINT(LOGGER_ALERT,TAGS,MSG)
#define CLOG (   MSG)    LOGGER_LOGPOINT(LOGGER_CRITICAL,"",MSG)
#define CLOGT (   TAGS,
  MSG 
)    LOGGER_LOGPOINT(LOGGER_CRITICAL,TAGS,MSG)
#define DLOG (   MSG)    LOGGER_LOGPOINT(LOGGER_DEBUG,"",MSG)

Referenced by nidas::util::McSocketListener::add(), nidas::dynld::raf::SyncRecordGenerator::addSampleClient(), nidas::core::TimetagAdjuster::adjust(), nidas::core::IOStream::backup(), nidas::core::SerialSensor::buildSampleScanner(), nidas::dynld::GPS_NMEA_Serial::buildSampleScanner(), nidas::core::FsMount::cancel(), nidas::core::NidasApp::checkRequiredArguments(), nidas::dynld::psql::PSQLSampleOutput::clone(), nidas::core::SampleOutputBase::close(), nidas::util::ServerSocket::close(), nidas::dynld::SampleInputStream::closeBlocks(), nidas::util::FileSet::closeFile(), nidas::dynld::psql::PSQLChannel::connect(), nidas::dynld::psql::PSQLSampleOutput::connect(), nidas::dynld::StatisticsCruncher::connect(), nidas::dynld::raf::SyncRecordSource::connect(), nidas::dynld::XMLConfigService::connected(), nidas::dynld::psql::PSQLSampleOutput::connected(), nidas::core::DSMEngine::connectOutputs(), copy_variables_to_record(), DataStats::createCounters(), nidas::util::FileSet::createDirectory(), nidas::util::FileSet::createFile(), nidas::core::DOMObjectFactory::createObject(), nidas::dynld::isff::CSAT3_Sonic::dataMode(), dataToInfluxDB(), nidas::core::SampleOutputRequestThread::destroyInstance(), nidas::dynld::psql::PSQLSampleOutput::dropAllTables(), nidas::dynld::raf::SyncRecordReader::endOfStream(), nidas::core::DSMEngineIntf::SensorAction::execute(), nidas::core::Project::findDSM(), nidas::dynld::isff::PacketInputStream::findSampleTag(), nidas::core::SampleSorter::flush(), nidas::dynld::raf::SyncRecordSource::flush(), nidas::dynld::psql::PSQLSampleOutput::fromDOMElement(), nidas::dynld::raf::DSMArincSensor::fromDOMElement(), nidas::dynld::raf::DSMAnalogSensor::getA2DSetup(), nidas::util::Inet4NetworkInterface::getInterface(), nidas::dynld::SampleInputStream::handleEOF(), nidas::dynld::SampleInputStream::handleNewInput(), InfluxDB::handleResult(), nidas::core::SampleSorter::heapDecrement(), nidas::dynld::raf::SyncRecordGenerator::init(), nidas::dynld::psql::PSQLSampleOutput::init(), nidas::dynld::raf::SyncServer::init(), nidas::dynld::raf::SyncRecordReader::init(), nidas::util::FileSet::initialize(), nidas::dynld::psql::PSQLSampleOutput::initializeGlobalAttributes(), nidas::dynld::raf::SyncServer::initProject(), nidas::dynld::raf::SyncServer::interrupt(), nidas::core::DSMEngine::joinDataThreads(), nidas::core::DSMServerApp::killStatusThread(), nidas::core::DSMServerApp::killXmlRpcThread(), nidas::core::DSMEngine::killXmlRpcThread(), PConfig::loadVariables(), nidas::core::NidasApp::lockMemory(), main(), nidas::core::DSMServerApp::main(), nidas::util::FileSet::matchFiles(), nidas::dynld::isff::CSAT3_Sonic::open(), nidas::util::FileSet::openNextFile(), nidas::dynld::raf::SyncServer::openStream(), nidas::core::Polynomial::parseFields(), nidas::dynld::SampleInputStream::parseInputHeader(), NidsMerge::parseRunstring(), nidas::dynld::iss::WICORSensor::process(), nidas::dynld::raf::UDPArincSensor::process(), nidas::dynld::raf::DSMArincSensor::processAlta(), nidas::dynld::raf::TwoD64_USB::processImageRecord(), nidas::core::SamplePool< SampleType >::putSample(), nidas::dynld::isff::CSAT3_Sonic::querySonic(), nidas::dynld::raf::SyncServer::read(), nidas::dynld::SampleInputStream::read(), nidas::core::SampleScanner::readBuffer(), nidas::core::VariableConverter::readCalFile(), DataStats::readHeader(), nidas::dynld::SampleInputStream::readInputHeader(), nidas::dynld::DSC_FreqCounter::readParams(), nidas::dynld::isff::PacketInputStream::readSamples(), nidas::core::DSMSensor::readSamples(), DataStats::readSamples(), nidas::core::IOStream::reallocateBuffer(), nidas::core::SampleSorter::receive(), DataStats::receive(), SampleDispatcher::receive(), nidas::dynld::raf::DSMArincSensor::registerWithUDPArincSensor(), nidas::core::MultipleUDPSockets::removeClient(), nidas::dynld::psql::PSQLSampleOutput::requestConnection(), nidas::core::requestXMLConfig(), PConfig::resolveCalFile(), DataStats::restartStats(), NidsMerge::run(), TeeTTy::run(), StatsProcess::run(), nidas::dynld::raf::SyncServer::run(), DataPrep::run(), nidas::dynld::RawSampleService::Worker::run(), nidas::core::Socket::ConnectionThread::run(), nidas::core::ServerSocket::ConnectionThread::run(), nidas::util::McSocketListener::run(), nidas::util::McSocketMulticaster< SocketTT >::run(), DataStats::run(), SampleDispatcher::SampleDispatcher(), nidas::core::SamplePool< SampleType >::SamplePool(), nidas::dynld::WxtSensor::scanSample(), nidas::dynld::SampleInputStream::search(), nidas::dynld::raf::PSI9116_Sensor::sendCommand(), InfluxDB::sendData(), nidas::dynld::raf::DSMMesaSensor::sendFPGACodeToDriver(), nidas::dynld::raf::SyncRecordGenerator::sendHeader(), nidas::core::CharacterSensor::sendInitString(), nidas::dynld::isff::CSAT3_Sonic::sendRateCommand(), nidas::dynld::raf::SyncRecordSource::sendSyncHeader(), nidas::dynld::isff::WindOrienter::setOrientation(), nidas::dynld::raf::SyncServer::setTimeWindow(), nidas::core::Looper::setupClientMaps(), nidas::core::NidasApp::setupProcess(), nidas::util::Thread::sigAction(), nidas::dynld::raf::SyncServer::signalStop(), nidas::dynld::raf::SyncServer::stop(), nidas::dynld::raf::PSI9116_Sensor::stopStreams(), nidas::dynld::isff::CSAT3_Sonic::terminalMode(), nidas::dynld::raf::DSMAnalogSensor::testVoltage(), nidas::dynld::isff::NCAR_TRH::validate(), nidas::dynld::isff::Wind2D::validate(), nidas::dynld::isff::Wind2D::validateSscanfs(), nidas::dynld::WxtSensor::wxtValidateSscanfs(), nidas::core::SampleSorter::~SampleSorter(), nidas::core::ServerSocket::~ServerSocket(), nidas::dynld::raf::SyncRecordReader::~SyncRecordReader(), and nidas::dynld::raf::SyncServer::~SyncServer().

#define DLOGT (   TAGS,
  MSG 
)    LOGGER_LOGPOINT(LOGGER_DEBUG,TAGS,MSG)
#define ELOGT (   TAGS,
  MSG 
)    LOGGER_LOGPOINT(LOGGER_EMERG,TAGS,MSG)
#define ILOG (   MSG)    LOGGER_LOGPOINT(LOGGER_INFO,"",MSG)

Referenced by nidas::core::SensorHandler::add(), nidas::core::MultipleUDPSockets::addClient(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::addDestination(), nidas::dynld::StatisticsProcessor::addRequestedSampleTag(), nidas::dynld::isff::GOESOutput::addSourceSampleTag(), nidas::dynld::StatisticsCruncher::attach(), nidas::core::FsMount::autoMount(), nidas::dynld::isff::SE_GOESXmtr::checkStatus(), nidas::util::SerialPort::close(), nidas::dynld::raf::SyncRecordGenerator::connect(), nidas::dynld::raf::CVIProcessor::connect(), nidas::core::SampleArchiver::connect(), nidas::core::ServerSocket::connect(), nidas::core::MultipleUDPSockets::connected(), nidas::util::FileSet::createDirectory(), nidas::util::FileSet::createFile(), InfluxDB::createInfluxDB(), nidas::dynld::isff::CSAT3_Sonic::dataMode(), nidas::dynld::isff::SE_GOESXmtr::decodeClock(), nidas::dynld::isff::SE_GOESXmtr::detectModel(), nidas::dynld::raf::SyncRecordGenerator::disconnect(), nidas::core::SampleArchiver::disconnect(), nidas::core::SampleOutputBase::disconnect(), nidas::dynld::isff::SE_GOESXmtr::doSelfTest(), nidas::dynld::raf::DSMMesaSensor::DSMMesaSensor(), InfluxDB::flush(), nidas::core::Project::fromDOMElement(), nidas::core::RemoteSerialConnection::handlePollEvents(), nidas::core::SensorHandler::handlePollingChange(), nidas::dynld::isff::NCAR_TRH::handleRawRH(), nidas::dynld::isff::NCAR_TRH::handleRawT(), nidas::core::SensorHandler::incrementFullBufferReads(), nidas::core::DSMServer::joinServices(), DataStats::jsonReport(), StatsProcess::listOutputSamples(), PConfig::loadRemoteXML(), nidas::core::NidasApp::lockMemory(), main(), nidas::core::DSMEngine::main(), PConfig::main(), nidas::core::FsMount::mount(), nidas::dynld::raf::DSMMesaSensor::open(), nidas::util::SerialPort::open(), nidas::dynld::raf::DSMArincSensor::open(), nidas::core::CalFile::open(), nidas::util::FileSet::openNextFile(), nidas::dynld::raf::SyncRecordSource::preLoadCalibrations(), nidas::dynld::isff::CSI_IRGA_Sonic::process(), nidas::util::Thread::pRun(), nidas::dynld::isff::WisardMote::readHead(), nidas::util::SocketImpl::receive(), SampleCounter::receive(), nidas::util::SocketImpl::recv(), nidas::util::SocketImpl::recvfrom(), nidas::core::Project::removeAutoConfig(), nidas::core::MultipleUDPSockets::removeClient(), DataStats::report(), nidas::core::ServerSocket::requestConnection(), nidas::dynld::isff::SE_GOESXmtr::reset(), nidas::core::StatusListener::run(), StatsProcess::run(), nidas::core::Looper::run(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::run(), DataPrep::run(), nidas::core::DSMServerStat::run(), nidas::dynld::UDPSampleOutput::XMLSocketListener::run(), nidas::core::SampleSorter::run(), WriterThread::run(), ServerThread::run(), nidas::util::McSocketListener::run(), nidas::util::McSocketMulticaster< SocketTT >::run(), DataStats::run(), nidas::dynld::raf::DSMMesaSensor::selectfiletype(), nidas::dynld::raf::DSMMesaSensor::sendFPGACodeToDriver(), nidas::dynld::raf::SppSerial::sendInitPacketAndCheckAck(), nidas::dynld::raf::UHSAS_Serial::sendInitString(), nidas::util::SocketImpl::setNonBlocking(), nidas::util::SocketImpl::setTcpNoDelay(), nidas::core::Looper::setupClientMaps(), InfluxDB::setUser(), nidas::util::Thread::thr_cleanup(), nidas::core::NidasApp::throw(), nidas::core::DSMServerApp::waitForSignal(), nidas::core::DSMEngine::waitForSignal(), nidas::core::MultipleUDPSockets::write(), nidas::core::SampleSorter::~SampleSorter(), and nidas::dynld::raf::SyncRecordSource::~SyncRecordSource().

#define ILOGT (   TAGS,
  MSG 
)    LOGGER_LOGPOINT(LOGGER_INFO,TAGS,MSG)
#define LOG_ALERT   LOG_CONTEXT(LOGGER_ALERT)
#define LOG_CONTEXT (   LEVEL)    nidas::util::LEVEL, __FILE__, __PRETTY_FUNCTION__, __LINE__
#define LOG_CRIT   LOG_CONTEXT(LOGGER_CRIT)
#define LOG_DEBUG   LOG_CONTEXT(LOGGER_DEBUG)
#define LOG_EMERG   LOG_CONTEXT(LOGGER_EMERG)
#define LOG_ERR   LOG_CONTEXT(LOGGER_ERR)

Referenced by nidas::dynld::isff::GOESOutput::addSourceSampleTag(), nidas::core::DSMService::cancel(), nidas::dynld::isff::GOESOutput::cancelThread(), nidas::core::DSMService::checkSubThreads(), nidas::dynld::UDPSampleOutput::clone(), nidas::dynld::raf::PPT_Serial::close(), nidas::core::DSMEngine::closeOutputs(), nidas::dynld::raf::SyncRecordSource::computeSlotIndex(), nidas::dynld::psql::PSQLProcessor::connected(), nidas::dynld::SampleProcessor::disconnect(), nidas::dynld::RawSampleService::disconnect(), nidas::dynld::raf::SyncRecordGenerator::disconnect(), nidas::dynld::raf::CVIProcessor::disconnect(), nidas::core::SampleArchiver::disconnect(), nidas::dynld::StatisticsProcessor::disconnect(), nidas::core::DSMEngine::disconnect(), nidas::core::GetAdsFileName::execute(), nidas::core::Project::getUniqueSampleId(), nidas::dynld::isff::GOESOutput::GOESOutput(), nidas::dynld::psql::PSQLSampleOutput::init(), nidas::core::DSMService::interrupt(), nidas::core::DSMService::join(), nidas::util::McSocket< SocketT >::joinMulticaster(), nidas::dynld::isff::GOESOutput::joinThread(), nidas::dynld::isff::GOESOutput::killThread(), nidas::core::SerialSensor::Prompter::looperNotify(), nidas::dynld::raf::SyncRecordSource::nextRecord(), nidas::dynld::raf::DSMAnalogSensor::open(), nidas::dynld::raf::LamsSensor::printStatus(), nidas::dynld::DSC_A2DSensor::printStatus(), nidas::dynld::DSC_FreqCounter::printStatus(), nidas::dynld::raf::DSMAnalogSensor::printStatus(), nidas::dynld::DSC_Event::printStatus(), nidas::dynld::DSC_PulseCounter::printStatus(), nidas::dynld::raf::IRIGSensor::printStatus(), nidas::dynld::raf::TwoD_USB::printStatus(), nidas::dynld::raf::DSMArincSensor::printStatus(), nidas::core::SerialSensor::printStatus(), nidas::dynld::raf::CVIOutput::receive(), nidas::dynld::UDPSampleOutput::receive(), nidas::dynld::AsciiOutput::receive(), nidas::dynld::psql::PSQLSampleOutput::receive(), nidas::dynld::raf::CVIProcessor::receive(), nidas::dynld::isff::GOESOutput::receive(), nidas::dynld::raf::SyncRecordSource::receive(), nidas::dynld::isff::GOESOutput::run(), nidas::dynld::RawSampleService::Worker::run(), nidas::core::Socket::ConnectionThread::run(), nidas::dynld::RawSampleService::schedule(), nidas::dynld::isff::GOESOutput::setIOChannel(), nidas::dynld::UDPSampleOutput::UDPSampleOutput(), nidas::dynld::raf::CVIProcessor::~CVIProcessor(), nidas::core::SampleArchiver::~SampleArchiver(), nidas::dynld::SampleProcessor::~SampleProcessor(), nidas::dynld::StatisticsProcessor::~StatisticsProcessor(), and nidas::dynld::raf::SyncRecordGenerator::~SyncRecordGenerator().

#define LOG_INFO   LOG_CONTEXT(LOGGER_INFO)
#define LOG_NOTICE   LOG_CONTEXT(LOGGER_NOTICE)
#define LOG_STATIC_CONTEXT (   LEVEL)    nidas::util::LEVEL, __FILE__, "file_static_scope", __LINE__

Expand to LogContext tuple outside function scope.

Use this macro to expand to the LogContext arguments when not inside a function, when PRETTY_FUNCTION is not valid.

#define LOG_VERBOSE   LOG_CONTEXT(LOGGER_VERBOSE)
#define LOG_WARNING   LOG_CONTEXT(LOGGER_WARNING)

Referenced by nidas::core::DSMSensor::addSampleTag(), nidas::dynld::raf::IRIGSensor::checkClock(), nidas::dynld::SampleInputStream::closeBlocks(), nidas::dynld::RawSampleService::connect(), nidas::dynld::XMLConfigService::connected(), nidas::dynld::isff::GOESOutput::connected(), nidas::dynld::StatisticsProcessor::connectSource(), nidas::dynld::raf::AlicatSDI::derivedDataNotify(), nidas::core::RemoteSerialConnection::doEscCmds(), nidas::core::Project::findDSM(), nidas::core::MultipleUDPSockets::fromDOMElement(), nidas::core::DSMService::fromDOMElement(), nidas::core::McSocketUDP::fromDOMElement(), nidas::core::McSocket::fromDOMElement(), nidas::core::DSMConfig::fromDOMElement(), nidas::core::DSMSensor::fromDOMElement(), nidas::core::DSMSensor::getLooper(), nidas::core::Socket::getRemoteInet4Address(), nidas::dynld::isff::PacketInputStream::init(), nidas::dynld::raf::TwoD64_USB::init_parameters(), nidas::dynld::isff::MOSMote::MOS_TimeSyncer::looperNotify(), nidas::dynld::raf::VCSEL2_Serial::open(), nidas::dynld::raf::AlicatSDI::open(), nidas::dynld::raf::VCSEL_Serial::open(), nidas::dynld::raf::TwoD_USB::open(), nidas::dynld::raf::LamsSensor::open(), nidas::dynld::raf::PIP_Serial::open(), nidas::dynld::raf::PSI9116_Sensor::process(), nidas::core::DatagramSampleScanner::readBuffer(), nidas::dynld::ParoSci_202BG_Calibration::readCalFile(), nidas::dynld::raf::DSMAnalogSensor::readCalFile(), nidas::dynld::raf::A2D_Serial::readCalFile(), nidas::dynld::isff::Wind3D::readOffsetsAnglesCalFile(), nidas::dynld::isff::PacketInputStream::readSamples(), nidas::dynld::UDPSampleOutput::receive(), nidas::dynld::raf::SyncRecordSource::receive(), SensorExtract::run(), nidas::core::SensorHandler::run(), nidas::dynld::SampleInputStream::sampleFromHeader(), nidas::dynld::raf::SyncRecordSource::selectVariablesFromSensor(), nidas::dynld::raf::TwoD_USB::sendTrueAirspeed(), nidas::core::CharacterSensor::validateSscanfs(), nidas::core::SampleBuffer::~SampleBuffer(), and nidas::core::ServerSocket::~ServerSocket().

#define LOGGER_LOGPOINT (   LEVEL,
  TAGS,
  MSG 
)
Value:
do { \
static nidas::util::LogContext logctxt \
(nidas::util::LEVEL, __FILE__,__PRETTY_FUNCTION__, \
__LINE__,TAGS); \
if (logctxt.active()) \
logctxt.log(nidas::util::LogMessage().format MSG); } \
while (0)
The LogContext is created at a point in the application code and filled in with details about that lo...
Definition: Logger.h:382
A class for formatting and streaming a log message.
Definition: Logger.h:895
if(!fp)
Definition: sing.cc:929
LogMessage & format(const char *fmt,...)
Definition: Logger.cc:561

This macro creates a static LogContext instance that is not in thread-local storage and therefore is not thread-safe.

The active flag will be written from any thread which changes the log configuration, and reads of the active flag happen in all threads which execute this log point. TLS was implemented at one point, but it turned out not to be portable enough. Locking is not really warranted given that in practice logging configurations do not change during runtime.

If thread-safety is required, then an automatic lock can be added to the beginning of the do-while block. I don't think the static initialization needs to happen inside the lock, at least for GCC. GCC already guards static initialization, but helgrind or DRD may not be able to recognize that without surrounding the block with a pthread lock. The actual check of the active flag probably should be thread-safe, since presumably one thread will initially write it and then multiple threads will read it. If the write happens inside the guard and only reads happen outside, then maybe that's safe enough since the reconfiguration of running log points does not happen in practice.

The lock used cannot be the global logging lock unless it is unlocked before calling the log() method, since the global lock is locked by the log() method and the lock is not recurisve. One goal for all this is to make things look reasonable and consistent to program checkers like helgrind.

The VERBOSE log level is intended for very verbose log messages which typically would only be used by developers. They are never enabled by a default LogConfig, they are above the DEBUG threshold, and in practice their overhead should be minimized by testing whether the log point is active() before generating any log output. It should be safe to compile them into code, and that should be preferred over surrounding them in a pre-processor conditional compilation block.

#define NLOG (   MSG)    LOGGER_LOGPOINT(LOGGER_NOTICE,"",MSG)
#define NLOGT (   TAGS,
  MSG 
)    LOGGER_LOGPOINT(LOGGER_NOTICE,TAGS,MSG)
#define PLOG (   MSG)    LOGGER_LOGPOINT(LOGGER_ERR,"",MSG)

Referenced by nidas::core::SensorHandler::add(), nidas::core::FsMount::cancel(), nidas::dynld::isff::SE_GOESXmtr::cancelTransmit(), nidas::core::NidasApp::checkPidFile(), nidas::dynld::UDPSampleOutput::XMLSocketListener::checkWorkers(), nidas::core::DerivedDataReader::deleteInstance(), nidas::dynld::psql::PSQLSampleOutput::dropAllTables(), nidas::core::StatusHandler::error(), nidas::core::DSMEngineIntf::DSMAction::execute(), nidas::core::DSMEngineIntf::SensorAction::execute(), nidas::dynld::raf::PSI9116_Sensor::executeXmlRpc(), nidas::dynld::raf::DSMAnalogSensor::executeXmlRpc(), nidas::core::StatusHandler::fatalError(), nidas::dynld::UDPSampleOutput::XMLSocketListener::fireWorkers(), nidas::dynld::raf::DSMAnalogSensor::getA2DSetup(), nidas::core::NidasApp::getHostName(), StatsProcess::getStatisticsProcessor(), nidas::core::RemoteSerialListener::handlePollEvents(), nidas::core::RemoteSerialConnection::handlePollEvents(), nidas::core::SensorHandler::PolledDSMSensor::handlePollEvents(), nidas::core::SensorHandler::NotifyPipe::handlePollEvents(), nidas::util::McSocketListener::interrupt(), nidas::util::McSocketMulticaster< SocketTT >::interrupt(), nidas::core::DSMEngine::joinDataThreads(), StatsProcess::listOutputSamples(), PacketReader::loop(), main(), nidas::core::DSMServerApp::main(), nidas::core::DSMEngine::main(), nidas::dynld::raf::UDPArincSensor::open(), nidas::dynld::isff::CSAT3_Sonic::open(), nidas::dynld::SampleInputStream::parseInputHeader(), nidas::dynld::isff::SE_GOESXmtr::printStatus(), nidas::dynld::iss::TiltSensor::process(), nidas::core::SensorHandler::remove(), nidas::core::requestXMLConfig(), nidas::core::SampleOutputRequestThread::run(), nidas::core::StatusListener::run(), nidas::core::DerivedDataReader::run(), TeeTTy::run(), nidas::core::DSMServerApp::run(), StatsProcess::run(), nidas::core::SensorOpener::run(), nidas::core::DSMEngine::run(), TeeI2C::run(), nidas::dynld::isff::GOESOutput::run(), DataPrep::run(), nidas::core::SensorHandler::run(), nidas::core::FsMountWorkerThread::run(), ServerThread::run(), nidas::util::ThreadJoiner::run(), nidas::core::FileSet::setNonBlocking(), nidas::core::StatusListener::StatusListener(), nidas::dynld::raf::DSMAnalogSensor::testVoltage(), nidas::dynld::isff::SE_GOESXmtr::transmitData(), nidas::core::DSMServerApp::waitForSignal(), nidas::core::DSMEngine::waitForSignal(), nidas::core::SensorHandler::NotifyPipe::~NotifyPipe(), nidas::core::RemoteSerialListener::~RemoteSerialListener(), and nidas::util::Thread::~Thread().

#define PLOGT (   TAGS,
  MSG 
)    LOGGER_LOGPOINT(LOGGER_ERR,TAGS,MSG)
#define VLOG (   MSG)    LOGGER_LOGPOINT(LOGGER_VERBOSE,"",MSG)

Referenced by nidas::util::SocketImpl::accept(), nidas::util::McSocket< SocketT >::accept(), nidas::util::McSocketListener::accept(), nidas::util::McSocketListener::add(), InfluxDB::addMeasurement(), nidas::dynld::isff::WisardMote::addMoteSampleTag(), nidas::core::SamplePipeline::addSampleClient(), CharBuffer::CharBuffer(), nidas::util::UTime::checkParse(), nidas::dynld::SampleOutputStream::close(), nidas::util::SocketImpl::close(), nidas::util::McSocket< SocketT >::close(), nidas::util::McSocketListener::close(), nidas::core::SampleArchiver::connect(), nidas::util::McSocket< SocketT >::connect(), nidas::dynld::StatisticsCruncher::createCombinations(), nidas::core::Site::findDSM(), nidas::core::Site::findSensor(), SampleDispatcher::findStats(), nidas::dynld::SampleOutputStream::flush(), nidas::dynld::SampleInputStream::flush(), nidas::util::SocketImpl::getInterface(), nidas::util::SocketImpl::getInterfaces(), nidas::util::SocketImpl::getLocalAddr(), nidas::util::SocketImpl::getReceiveBufferSize(), nidas::util::SocketImpl::getRemoteAddr(), nidas::util::SocketImpl::getSendBufferSize(), StatsProcess::getStatisticsProcessor(), nidas::dynld::SampleInputStream::handleNewInput(), DataStats::hashId(), TeeI2C::i2c_byte_reads(), nidas::util::SocketImpl::joinGroup(), nidas::util::McSocket< SocketT >::joinMulticaster(), nidas::util::listMulticastInterfaces(), PacketReader::loop(), DataPrep::matchVariables(), CharBuffer::operator=(), nidas::util::EndianConverter::privGetHostEndianness(), nidas::dynld::isff::CSAT3_Sonic::process(), nidas::dynld::isff::WisardMote::process(), nidas::core::SamplePipeline::procinit(), nidas::core::SamplePipeline::rawinit(), nidas::core::IOStream::read(), nidas::dynld::SampleInputStream::read(), nidas::core::CalFile::readCFInclude(), nidas::dynld::isff::WisardMote::readHead(), nidas::core::CalFile::readLine(), nidas::dynld::SampleInputStream::readSamples(), nidas::core::IOStream::reallocateBuffer(), nidas::dynld::SampleOutputStream::receive(), SampleCounter::receive(), DataStats::receive(), SampleDispatcher::receive(), nidas::util::McSocketListener::remove(), nidas::core::Project::removeAutoConfig(), nidas::core::Looper::run(), DataPrep::run(), WriterThread::run(), nidas::util::McSocketListener::run(), nidas::util::McSocketMulticaster< SocketTT >::run(), nidas::dynld::WxtSensor::scanSample(), nidas::util::SocketImpl::send(), nidas::core::CalFile::setDateTimeFormat(), nidas::core::CalFile::setTimeZone(), nidas::dynld::isff::WisardMote::unpackAccumSec(), nidas::dynld::isff::WisardMote::validate(), TeeI2C::writeptys(), nidas::dynld::SampleOutputStream::~SampleOutputStream(), and nidas::core::SampleSorter::~SampleSorter().

#define VLOGT (   TAGS,
  MSG 
)    LOGGER_LOGPOINT(LOGGER_VERBOSE,TAGS,MSG)
#define WLOG (   MSG)    LOGGER_LOGPOINT(LOGGER_WARNING,"",MSG)

Referenced by nidas::core::VariableConverter::abortCalFile(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::addConnection(), nidas::dynld::isff::WisardMote::addMoteSampleTag(), nidas::dynld::StatisticsCruncher::attach(), nidas::core::IOStream::backup(), nidas::util::SocketImpl::bind(), nidas::dynld::raf::A2D_Serial::checkCkSum(), nidas::dynld::isff::SE_GOESXmtr::checkClock(), nidas::dynld::raf::Watlow::checkCRC(), nidas::dynld::isff::WisardMote::checkCRC(), nidas::dynld::isff::WisardMote::checkEOM(), nidas::dynld::isff::SE_GOESXmtr::checkId(), nidas::core::SensorHandler::PolledDSMSensor::checkTimeout(), nidas::dynld::SampleInputStream::checkUnexpectedEOF(), nidas::dynld::RawSampleService::connect(), nidas::core::SampleArchiver::connect(), nidas::core::NearestResampler::connect(), nidas::core::SampleAverager::connect(), nidas::dynld::StatisticsCruncher::connect(), nidas::core::NearestResamplerAtRate::connect(), nidas::dynld::UDPSampleOutput::connected(), nidas::util::FileSet::createFile(), nidas::dynld::raf::SyncRecordSource::createHeader(), nidas::dynld::isff::WisardMote::createSampleTag(), nidas::dynld::isff::SE_GOESXmtr::decodeClock(), nidas::core::SampleOutputRequestThread::destroyInstance(), nidas::dynld::RawSampleService::disconnect(), nidas::core::Project::findDSM(), nidas::core::Project::findServerSampleOutputStreamFileSets(), nidas::dynld::SampleOutputStream::flush(), nidas::core::SampleSorter::flush(), nidas::core::DatagramSocket::fromDOMElement(), nidas::core::DSMConfig::fromDOMElement(), nidas::core::Socket::fromDOMElement(), nidas::core::SampleOutputBase::fromDOMElement(), nidas::core::Variable::fromDOMElement(), nidas::dynld::SampleInputStream::fromDOMElement(), nidas::util::Inet4Address::getHostName(), nidas::dynld::isff::SE_GOESXmtr::getSelfTestResults(), nidas::core::MultipleUDPSockets::handleChangedSockets(), nidas::core::SensorHandler::PolledDSMSensor::handlePollEvents(), nidas::dynld::raf::DSMArincSensor::init(), nidas::core::XmlRpcThread::interrupt(), nidas::core::SensorOpener::interrupt(), nidas::core::DerivedDataReader::interrupt(), nidas::core::SamplePipeline::join(), nidas::core::DSMEngine::joinDataThreads(), nidas::core::DSMServerApp::killStatusThread(), nidas::core::DSMServerApp::killXmlRpcThread(), nidas::core::DSMEngine::killXmlRpcThread(), nidas::core::NidasApp::lockMemory(), PacketReader::logBadPacket(), nidas::core::SensorHandler::NotifyPipe::notify(), nidas::dynld::isff::CSAT3_Sonic::open(), nidas::dynld::raf::A2D_Serial::parseConfigLine(), nidas::core::Polynomial::parseFields(), nidas::dynld::isff::CSI_IRGA_Sonic::parseParameters(), nidas::dynld::isff::SE_GOESXmtr::printStatus(), nidas::dynld::raf::Watlow::process(), nidas::dynld::raf::LamsNetSensor::process(), nidas::dynld::GPS_Novatel_Serial::process(), nidas::dynld::GPS_NMEA_Serial::process(), nidas::dynld::raf::UHSAS_Serial::process(), nidas::dynld::raf::PPT_Serial::process(), nidas::dynld::raf::UDPArincSensor::process(), nidas::dynld::raf::DSMArincSensor::process(), nidas::dynld::isff::WisardMote::process(), nidas::dynld::raf::DSMArincSensor::processAlta(), nidas::dynld::raf::TwoD32_USB::processImage(), nidas::dynld::raf::TwoD64_USB::processImageRecord(), nidas::dynld::raf::A2D_Serial::readConfig(), nidas::dynld::isff::WisardMote::readHead(), nidas::dynld::SampleOutputStream::receive(), nidas::dynld::isff::GOESOutput::receive(), nidas::dynld::StatisticsCruncher::receive(), nidas::core::NearestResampler::receive(), nidas::core::SampleSorter::receive(), nidas::core::NearestResamplerAtRate::receive(), nidas::util::SocketImpl::receive(), SampleDispatcher::receive(), nidas::core::SensorHandler::remove(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::removeConnection(), nidas::dynld::isff::CU_Coldwire::reportBadChecksum(), nidas::dynld::isff::CSI_CRX_Binary::reportBadCRC(), nidas::dynld::isff::CSI_IRGA_Sonic::reportBadCRC(), nidas::core::DerivedDataReader::run(), TeeTTy::run(), StatsProcess::run(), nidas::core::SensorOpener::run(), TeeI2C::run(), nidas::core::DSMEngineStat::run(), nidas::dynld::isff::GOESOutput::run(), DataPrep::run(), nidas::core::DSMServerStat::run(), nidas::dynld::RawSampleService::Worker::run(), nidas::core::SampleBuffer::run(), nidas::core::SampleSorter::run(), WriterThread::run(), ServerThread::run(), nidas::util::McSocketListener::run(), nidas::util::McSocketMulticaster< SocketTT >::run(), nidas::dynld::SampleInputStream::sampleFromHeader(), SampleToDatabase::SampleToDatabase(), nidas::dynld::WxtSensor::scanSample(), nidas::core::RemoteSerialConnection::sensorNotFound(), TeeTTy::setFIFOPriority(), TeeI2C::setFIFOPriority(), nidas::core::NidasApp::setupProcess(), nidas::util::Thread::start(), nidas::dynld::isff::CSAT3_Sonic::terminalMode(), nidas::dynld::isff::SE_GOESXmtr::testTransmitSE120(), nidas::core::NidasApp::throw(), nidas::core::DSMServerApp::waitForSignal(), nidas::core::DSMEngine::waitForSignal(), nidas::core::MessageStreamScanner::warnBackwardsStepTimeTag(), nidas::core::StatusHandler::warning(), nidas::core::MessageStreamScanner::warnNonIncrTimeTag(), nidas::core::IOStream::write(), TeeI2C::writeptys(), nidas::dynld::WxtSensor::wxtValidateSscanfs(), nidas::core::DatagramSocket::~DatagramSocket(), nidas::core::SampleSorter::~SampleSorter(), and nidas::core::Socket::~Socket().

#define WLOGT (   TAGS,
  MSG 
)    LOGGER_LOGPOINT(LOGGER_WARNING,TAGS,MSG)

Function Documentation

LogMessage& nidas::util::endlog ( LogMessage &  logmsg)
inline
template<typename T >
T nidas::util::LogScheme::getParameterT ( const std::string &  name,
const T &  dvalue = T() 
)

Lookup a parameter with name name in a LogScheme and convert the value to the type of the dvalue parameter.

If the parameter has not been set in this LogScheme or cannot be converted, then return dvalue.

Below is an example of using a log parameter to throttle the frequency of a log message. The first section retrieves the value from the currently active LogScheme, the second logs the message.

_discardWarningCount = 1000;
_discardWarningCount =
Logger::getScheme().getParameterT("_discard_warning_count",
_discardWarningCount);

Then use the parameter value like so:

if (!(_discardedSamples++ % _discardWarningCount))
WLOG(("%d samples discarded... ", _discardedSamples));

See the NidasApp class 'logparam' option to set a LogScheme parameter on the command-line.

References nidas::util::LogScheme::getParameter().

Referenced by nidas::dynld::GPS_NMEA_Serial::GPS_NMEA_Serial(), and nidas::core::SampleSorter::SampleSorter().

void nidas::util::LogContext::log ( const std::string &  msg) const
inline
LogMessage nidas::util::LogContext::log ( ) const
inline

Return a LogMessage associated with this LogContext, so the message will be logged through this context when the LogMessage goes out of scope.

Typically this is used as a temporary object to which the log message content can be streamed, which can be a little more convenient than formatting the message separately and then passing it to log(const std::string& msg). Also see the LogMessage() constructor which takes a LogContext.

static LogContext lp(LOG_INFO);
if (lp.active())
{
lp.log() << "complicated info output...";
}
std::string nidas::util::logLevelToString ( int  )

Convert an integral log level to a string name.

Returns
The name for the given log level, or else "emergency".

Referenced by nidas::util::LogContext::levelName().

template<typename T >
LogMessage & nidas::util::LogMessage::operator<< ( const T &  t)
inline

Everything streamed to a LogMessage is passed on to the underlying ostringstream, including ostream manipulators.

References nidas::util::LogMessage::msg.

LogMessage& nidas::util::operator<< ( LogMessage &  logmsg,
LogMessage &(*)(LogMessage &)  op 
)
inline

Template to call LogMessage manipulators like endlog when streamed to a LogMessage.

int nidas::util::stringToLogLevel ( const std::string &  slevel)

Convert the name of a log level to its integer value.

Returns
The log level value, or -1 if the name is not recognized.

References if(), nidas::util::LOGGER_NONE, and nidas::util::LOGGER_WARNING.

Referenced by LogSchemeFromDOMElement(), and parse_log_level().

Variable Documentation

const int nidas::util::LOGGER_ALERT = LOG_ALERT
const int nidas::util::LOGGER_CRIT = LOG_CRIT
const int nidas::util::LOGGER_CRITICAL = LOG_CRIT
const int nidas::util::LOGGER_DEBUG = LOG_DEBUG

Referenced by main().

const int nidas::util::LOGGER_EMERGENCY = LOG_EMERG
const int nidas::util::LOGGER_ERR = LOG_ERR
const int nidas::util::LOGGER_ERROR = LOG_ERR
const int nidas::util::LOGGER_INFO = LOG_INFO
const int nidas::util::LOGGER_NONE = LOG_EMERG-1
const int nidas::util::LOGGER_NOTICE = LOG_NOTICE
const int nidas::util::LOGGER_PROBLEM = LOG_ERR
const int nidas::util::LOGGER_VERBOSE = LOG_DEBUG+1
const int nidas::util::LOGGER_WARNING = LOG_WARNING