nidas v1.2.3
Public Member Functions | Protected Attributes | List of all members
nidas::util::LogContextState Class Reference

LogContextState holds the status members of a LogContext and related behavior. More...

#include <Logger.h>

Inheritance diagram for nidas::util::LogContextState:
Inheritance graph
[legend]

Public Member Functions

 LogContextState (int level, const char *file, const char *function, int line, const char *tags=0)
 The LogContextState constructor initializes all the static context information and also records the ID of the current thread.
 
bool active () const
 Return true if log messages from this context have been enabled.
 
void setActive (bool active)
 Enable this log point according to active.
 
const char * filename () const
 
const char * function () const
 
int line () const
 
int level () const
 
const char * tags () const
 
std::string threadName () const
 Return the name of the thread which created this context.
 
std::string levelName () const
 
void log (const std::string &msg) const
 Convenience method which writes the given message to the current Logger instance, passing this object as the LogContextState.
 
LogMessage log () const
 Return a LogMessage associated with this LogContextState, so the message will be logged through this context when the LogMessage goes out of scope.
 

Protected Attributes

int _level
 
const char * _file
 
const char * _function
 
int _line
 
const char * _tags
 
bool _active
 
pthread_t _threadId
 

Detailed Description

LogContextState holds the status members of a LogContext and related behavior.

It can be copied and saved but by itself has no connection to the global log points, so it's active flag does not change except through setActive().

Constructor & Destructor Documentation

◆ LogContextState()

LogContextState::LogContextState ( int level,
const char * file,
const char * function,
int line,
const char * tags = 0 )

The LogContextState constructor initializes all the static context information and also records the ID of the current thread.

Member Function Documentation

◆ active()

bool nidas::util::LogContextState::active ( ) const
inline

Return true if log messages from this context have been enabled.

If this returns false, then there is no point in generating and submitting a log message.

References _active.

Referenced by nidas::core::SampleTracer::active(), nidas::core::SampleTracer::active(), nidas::dynld::SampleInputStream::sampleFromHeader(), and setActive().

◆ filename()

const char * nidas::util::LogContextState::filename ( ) const
inline

References _file.

◆ function()

const char * nidas::util::LogContextState::function ( ) const
inline

References _function.

◆ level()

int nidas::util::LogContextState::level ( ) const
inline

References _level.

◆ levelName()

std::string nidas::util::LogContextState::levelName ( ) const
inline

◆ line()

int nidas::util::LogContextState::line ( ) const
inline

References _line.

◆ setActive()

void nidas::util::LogContextState::setActive ( bool active)
inline

Enable this log point according to active.

References _active, and active().

◆ tags()

const char * nidas::util::LogContextState::tags ( ) const
inline

References _tags.

◆ threadName()

std::string LogContextState::threadName ( ) const

Return the name of the thread which created this context.

This is not necessarily the name of the currently running thread, so it may not be the same as the thread named in a log message when LogScheme::ThreadField is enabled in the LogScheme.

References _threadId, and nidas::util::Thread::lookupThread().

Member Data Documentation

◆ _active

bool nidas::util::LogContextState::_active
protected

Referenced by active(), and setActive().

◆ _file

const char* nidas::util::LogContextState::_file
protected

Referenced by filename().

◆ _function

const char* nidas::util::LogContextState::_function
protected

Referenced by function().

◆ _level

int nidas::util::LogContextState::_level
protected

Referenced by level(), and levelName().

◆ _line

int nidas::util::LogContextState::_line
protected

Referenced by line().

◆ _tags

const char* nidas::util::LogContextState::_tags
protected

Referenced by tags().

◆ _threadId

pthread_t nidas::util::LogContextState::_threadId
protected

Referenced by threadName().


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