Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

atoms::DebugLogger Class Reference
[Debugging]

#include <debug.hh>

List of all members.


Detailed Description

A configurable logger.

Todo:
"Configurable" is overly optimistic right now. Eventually, I want this to have hierarchical configurable logging levels, like the Jakarta logging facility.

Definition at line 71 of file debug.hh.

[NOHEADER]

void init ()
pthread_once_t init_once = PTHREAD_ONCE_INIT

Public Types

enum  Level {
  lDebug = 0, lInfo, lMessage, lWarning,
  lError, lFatal
}

Public Member Functions

 DebugLogger (const char *loggerName)
Level getMinimumLevel () const
 Returns the minimum level to log.

void logFatal (const char *fmt,...)
 Logs a fatal error at high priority and exits.

void log (Level level, const char *fmt,...)
void vlog (Level level, const char *fmt, va_list)

Static Public Member Functions

void setFatalThrows (bool newValue)
 Sets whether a fatal error should throw a FatalError (true) or abort (false, default).


Static Public Attributes

const char * LEVEL_NAMES []

Private Member Functions

void findLevel () const

Private Attributes

const char * loggerName
bool levelFound
 If we've searched the configuration for our minimum level yet.

Level minimumLevel
 Any logs below this level are surpressed.


Static Private Attributes

bool fatalThrows
std::map< std::string, Levellevels
 A map of logger names to levels.

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER
 Synchronizes access.

const Level DEFAULT_LEVEL = DebugLogger::lMessage
 Default logging level.


Member Enumeration Documentation

enum atoms::DebugLogger::Level
 

Enumeration values:
lDebug 
lInfo 
lMessage 
lWarning 
lError 
lFatal 

Definition at line 76 of file debug.hh.

Referenced by getMinimumLevel(), and init().


Constructor & Destructor Documentation

atoms::DebugLogger::DebugLogger const char *  loggerName  )  [inline]
 

Definition at line 73 of file debug.hh.

References levelFound, and loggerName.


Member Function Documentation

void atoms::DebugLogger::findLevel  )  const [private]
 

Definition at line 138 of file debug.cc.

References DEFAULT_LEVEL, init_once, levelFound, levels, loggerName, minimumLevel, and NULL.

Referenced by getMinimumLevel(), and vlog().

DebugLogger::Level atoms::DebugLogger::getMinimumLevel  )  const
 

Returns the minimum level to log.

This is useful when doing expensive work to prepare a log message.

Definition at line 114 of file debug.cc.

References findLevel(), Level, levelFound, minimumLevel, mutex, and atoms::write().

Here is the call graph for this function:

void atoms::DebugLogger::init  )  [static, private]
 

Definition at line 63 of file debug.cc.

References std::getline(), std::ifstream, Level, LEVEL_NAMES, levels, loggerName, std::make_pair(), and NULL.

Here is the call graph for this function:

void atoms::DebugLogger::log Level  level,
const char *  fmt,
... 
 

Definition at line 159 of file debug.cc.

References args, and vlog().

Referenced by atoms::StreamSocket::accept(), atoms::EpollPoller::add(), atoms::Socket::attachInt(), atoms::Socket::bind(), atoms::UNIXDescriptor::cancelPoll(), atoms::UNIXDescriptor::close(), atoms::Socket::connect(), atoms::StreamSocket::createPair(), atoms::ssl::Context::doGlobalInitialization(), atoms::Thread::entry(), atoms::ssl::Error::Error(), atoms::KqueuePoller::KqueuePoller(), atoms::Error::logCaught(), atoms::TimeoutDispatcher::main(), atoms::DebugLogger::Mon::Mon(), atoms::KqueuePoller::poll(), atoms::UNIXDescriptor::pollForAvailability(), atoms::Buffer::prepareForAppend(), atoms::UNIXStream::read(), atoms::KqueuePoller::remove(), atoms::EpollPoller::remove(), atoms::Socket::Socket(), atoms::Process::throwExecError(), atoms::TimeoutDispatcher::TimeoutDispatcher(), atoms::Socket::tryConnect(), atoms::UNIXStream::write(), atoms::DebugLogger::Mon::~Mon(), atoms::~NonseekableBufferedStreamFilter(), and atoms::TimeoutDispatcher::~TimeoutDispatcher().

Here is the call graph for this function:

void atoms::DebugLogger::logFatal const char *  fmt,
... 
 

Logs a fatal error at high priority and exits.

Definition at line 215 of file debug.cc.

References args, lFatal, vlog(), and atoms::write().

Referenced by atoms::KqueuePoller::add(), atoms::EpollPoller::add(), atoms::Thread::atExit(), atoms::Socket::attachInt(), atoms::Socket::bind(), atoms::UNIXDescriptor::close(), atoms::Socket::connectError(), atoms::ssl::Context::Context(), atoms::StreamSocket::createPair(), atoms::Thread::entry(), atoms::ssl::Error::Error(), atoms::Socket::getAddress(), atoms::ssl::StreamFilter::ioCommon(), atoms::Thread::join(), atoms::KqueuePoller::KqueuePoller(), atoms::Mutex::Mon::lock(), atoms::UNIXStream::open(), atoms::KqueuePoller::poll(), atoms::EpollPoller::poll(), atoms::KqueuePoller::remove(), atoms::EpollPoller::remove(), atoms::EpollPoller::removeInternal(), atoms::UNIXStream::rwError(), atoms::SeekableUNIXStream::seek(), atoms::UNIXDescriptor::setCloseOnExec(), atoms::Socket::setTimeout(), atoms::StreamSocket::shutdown(), atoms::StackOnly::StackOnly(), atoms::Mutex::Mon::unlock(), atoms::Condition::~Condition(), and atoms::KqueuePoller::~KqueuePoller().

Here is the call graph for this function:

void atoms::DebugLogger::setFatalThrows bool  newValue  )  [inline, static]
 

Sets whether a fatal error should throw a FatalError (true) or abort (false, default).

This is useful in unit tests to check if error-handling code is working properly. Otherwise, there's little reason to want an exception; they're called fatal errors for a reason.

Definition at line 94 of file debug.hh.

References fatalThrows.

void atoms::DebugLogger::vlog Level  level,
const char *  fmt,
va_list 
 

Definition at line 171 of file debug.cc.

References args, fatalThrows, findLevel(), LEVEL_NAMES, levelFound, lFatal, loggerName, minimumLevel, mutex, atoms::Backtrace::print(), and atoms::write().

Referenced by log(), and logFatal().

Here is the call graph for this function:


Member Data Documentation

const DebugLogger::Level atoms::DebugLogger::DEFAULT_LEVEL = DebugLogger::lMessage [static, private]
 

Default logging level.

Definition at line 40 of file debug.cc.

Referenced by findLevel().

bool atoms::DebugLogger::fatalThrows [static, private]
 

Definition at line 38 of file debug.cc.

Referenced by setFatalThrows(), and vlog().

pthread_once_t atoms::DebugLogger::init_once = PTHREAD_ONCE_INIT [static, private]
 

Definition at line 43 of file debug.cc.

Referenced by findLevel().

const char * atoms::DebugLogger::LEVEL_NAMES [static]
 

Initial value:

 {
    "debug",
    "info",
    "message",
    "warning",
    "error",
    "fatal"
}

Definition at line 27 of file debug.cc.

Referenced by init(), and vlog().

bool atoms::DebugLogger::levelFound [mutable, private]
 

If we've searched the configuration for our minimum level yet.

Definition at line 142 of file debug.hh.

Referenced by DebugLogger(), findLevel(), getMinimumLevel(), and vlog().

map< string, DebugLogger::Level > atoms::DebugLogger::levels [static, private]
 

A map of logger names to levels.

Definition at line 42 of file debug.cc.

Referenced by findLevel(), and init().

const char* atoms::DebugLogger::loggerName [private]
 

Definition at line 139 of file debug.hh.

Referenced by DebugLogger(), findLevel(), init(), and vlog().

Level atoms::DebugLogger::minimumLevel [mutable, private]
 

Any logs below this level are surpressed.

Definition at line 145 of file debug.hh.

Referenced by findLevel(), getMinimumLevel(), and vlog().

pthread_mutex_t atoms::DebugLogger::mutex = PTHREAD_MUTEX_INITIALIZER [static, private]
 

Synchronizes access.

Definition at line 48 of file debug.cc.

Referenced by getMinimumLevel(), and vlog().


The documentation for this class was generated from the following files:
Generated on Wed Jun 15 01:20:47 2005 for atoms++ by doxygen 1.3.5