Back to index

nux  3.0.0
Classes | Typedefs | Enumerations | Functions
nux::logging Namespace Reference

Classes

class  LoggerModule
class  LoggerModules
class  LogStreamBuffer
class  LogStream
class  Logger
class  BlockTracer
 This class is used to log the entry and exit of a block. More...
class  Writer
class  RollingFileAppender

Typedefs

typedef boost::shared_ptr
< LoggerModule
LoggerModulePtr

Enumerations

enum  Level {
  NotSpecified, Trace, Debug, Info,
  Warning, Error, Critical
}

Functions

void reset_logging ()
 A helper function for testing.
std::string dump_logging_levels (std::string const &prefix)
void configure_logging (const char *config_string)
 Configure multiple logging modules.
Level get_logging_level (std::string level)
std::string Backtrace (int levels=-1)

Typedef Documentation

typedef boost::shared_ptr<LoggerModule> nux::logging::LoggerModulePtr

Definition at line 112 of file Logger.h.


Enumeration Type Documentation

Enumerator:
NotSpecified 
Trace 
Debug 
Info 
Warning 
Error 
Critical 

Definition at line 62 of file Logger.h.


Function Documentation

std::string nux::logging::Backtrace ( int  levels = -1)
void nux::logging::configure_logging ( const char *  config_string)

Configure multiple logging modules.

This function expects a string of the format: module=info;sub.module=debug;other.module=warning

The root module can be specified by using the value "<root>", eg: <root>=info;other.module=debug

The specified modules will have their logging level set to the specified level as defined by the get_logging_level function.

It is expected that this method is called during application startup with the content of some environment variable. nux::logging::configure_logging(::getenv("MY_APP_LOGGING_CONFIG"));

Definition at line 349 of file Logger.cpp.

{
  if (!config_string)
    return;
  std::vector<std::string> values;
  boost::split(values, config_string, boost::is_any_of(";:"));
  for (std::vector<std::string>::iterator i = values.begin(), end = values.end();
       i != end; ++i)
  {
    std::string& value = *i;
    std::string::size_type pos = value.find("=");
    if (pos != std::string::npos)
    {
      std::string name = value.substr(0, pos);
      std::string level = value.substr(pos+1);
      if (name == "<root>")
        name = "";
      Logger(name).SetLogLevel(get_logging_level(level));
    }
  }
}

Here is the call graph for this function:

std::string nux::logging::dump_logging_levels ( std::string const &  prefix)

Definition at line 344 of file Logger.cpp.

{
  return LoggerModules::Instance().dump_logging_levels(prefix);
}

Here is the call graph for this function:

Level nux::logging::get_logging_level ( std::string  level)

Definition at line 371 of file Logger.cpp.

{
  boost::to_upper(level);
  if (level == "TRACE")
    return Trace;
  if (level == "DEBUG")
    return Debug;
  if (level == "INFO")
    return Info;
  if (level == "WARN" || level == "WARNING")
    return Warning;
  if (level == "ERROR")
    return Error;
  return Warning;
}

Here is the caller graph for this function:

A helper function for testing.

Not exported, but used in tests.

Resets the root logger to warning, and sets all other modules to not specified.

Definition at line 339 of file Logger.cpp.

{
  LoggerModules::Instance().reset();
}

Here is the call graph for this function: