Changeset 68:b6821d4af878 in rrlib_logging


Ignore:
Timestamp:
29.12.2011 23:37:35 (9 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

New concept of domain creation and addressing. Messages are not printed, yet.

Files:
2 added
2 deleted
6 edited
1 copied
6 moved

Legend:

Unmodified
Added
Removed
  • configuration/tConfiguration.cpp

    r51 r68  
    2020// 
    2121//---------------------------------------------------------------------- 
    22 /*!\file    tLogDomainConfiguration.cpp 
     22/*!\file    tConfiguration.cpp 
    2323 * 
    2424 * \author  Tobias Foehst 
     
    2929//---------------------------------------------------------------------- 
    3030#define __rrlib__logging__include_guard__ 
    31 #include "rrlib/logging/tLogDomainConfiguration.h" 
     31#include "rrlib/logging/configuration/tConfiguration.h" 
    3232 
    3333//---------------------------------------------------------------------- 
    3434// External includes (system with <>, local with "") 
    3535//---------------------------------------------------------------------- 
    36 #ifdef _RRLIB_XML2_WRAPPER_PRESENT_ 
    37 #include <iostream> 
    38 #include "rrlib/xml2_wrapper/tXMLDocument.h" 
    39 #endif 
     36#include <cstring> 
    4037 
    4138//---------------------------------------------------------------------- 
    4239// Internal includes with "" 
    4340//---------------------------------------------------------------------- 
    44 #include "rrlib/logging/tLogDomain.h" 
    4541 
    4642//---------------------------------------------------------------------- 
     
    5147// Namespace usage 
    5248//---------------------------------------------------------------------- 
    53 using namespace rrlib::logging; 
    54  
    55 #ifdef _RRLIB_XML2_WRAPPER_PRESENT_ 
    56 using namespace rrlib::xml2; 
    57 #endif 
     49 
     50//---------------------------------------------------------------------- 
     51// Namespace declaration 
     52//---------------------------------------------------------------------- 
     53namespace rrlib 
     54{ 
     55namespace logging 
     56{ 
    5857 
    5958//---------------------------------------------------------------------- 
     
    8584 
    8685//---------------------------------------------------------------------- 
    87 // tLogDomainConfiguration constructors 
    88 //---------------------------------------------------------------------- 
    89 tLogDomainConfiguration::tLogDomainConfiguration(const std::string &name) 
    90     : name(name), 
    91     configure_sub_tree(false), 
    92     print_time(cDEFAULT_PRINT_TIME), 
    93     print_name(cDEFAULT_PRINT_NAME), 
    94     print_level(cDEFAULT_PRINT_LEVEL), 
    95     print_location(cDEFAULT_PRINT_LOCATION), 
    96     max_message_level(cDEFAULT_MAX_LOG_LEVEL), 
    97     sink_mask(cDEFAULT_SINK_MASK) 
     86// tConfiguration constructors 
     87//---------------------------------------------------------------------- 
     88tConfiguration::tConfiguration(const tConfiguration *parent, const std::string &name) 
     89    : parent(parent), 
     90    name(name)//, 
     91//    print_time(cDEFAULT_PRINT_TIME), 
     92//    print_name(cDEFAULT_PRINT_NAME), 
     93//    print_level(cDEFAULT_PRINT_LEVEL), 
     94//    print_location(cDEFAULT_PRINT_LOCATION), 
     95//    max_message_level(cDEFAULT_MAX_LOG_LEVEL), 
     96//    sink_mask(cDEFAULT_SINK_MASK) 
    9897{} 
    9998 
    100 tLogDomainConfiguration::tLogDomainConfiguration(const tLogDomainConfiguration &other) 
    101     : configure_sub_tree(other.configure_sub_tree), 
    102     print_time(other.print_time), 
    103     print_name(other.print_name), 
    104     print_level(other.print_level), 
    105     print_location(other.print_location), 
    106     max_message_level(other.max_message_level), 
    107     sink_mask(other.sink_mask) 
    108 {} 
    109  
    110 //---------------------------------------------------------------------- 
    111 // tLogDomainConfiguration operator = 
    112 //---------------------------------------------------------------------- 
    113 tLogDomainConfiguration &tLogDomainConfiguration::operator = (const tLogDomainConfiguration other) 
    114 { 
    115   this->configure_sub_tree = other.configure_sub_tree; 
    116   this->print_time = other.print_time; 
    117   this->print_name = other.print_name; 
    118   this->print_level = other.print_level; 
    119   this->print_location = other.print_location; 
    120   this->max_message_level = other.max_message_level; 
    121   this->sink_mask = other.sink_mask; 
    122   return *this; 
    123 } 
     99//tConfiguration::tConfiguration(const tConfiguration &other) 
     100//    : print_time(other.print_time), 
     101//    print_name(other.print_name), 
     102//    print_level(other.print_level), 
     103//    print_location(other.print_location), 
     104//    max_message_level(other.max_message_level), 
     105//    sink_mask(other.sink_mask) 
     106//{} 
     107// 
     108////---------------------------------------------------------------------- 
     109//// tConfiguration operator = 
     110////---------------------------------------------------------------------- 
     111//tConfiguration &tConfiguration::operator = (const tConfiguration other) 
     112//{ 
     113//  this->print_time = other.print_time; 
     114//  this->print_name = other.print_name; 
     115//  this->print_level = other.print_level; 
     116//  this->print_location = other.print_location; 
     117//  this->max_message_level = other.max_message_level; 
     118//  this->sink_mask = other.sink_mask; 
     119//  return *this; 
     120//} 
     121 
     122//---------------------------------------------------------------------- 
     123// tConfiguration destructor 
     124//---------------------------------------------------------------------- 
     125tConfiguration::~tConfiguration() 
     126{ 
     127  for (auto it = this->children.begin(); it != this->children.end(); ++it) 
     128  { 
     129    delete *it; 
     130  } 
     131} 
     132 
     133//---------------------------------------------------------------------- 
     134// tConfiguration GetConfigurationByName 
     135//---------------------------------------------------------------------- 
     136const tConfiguration &tConfiguration::GetConfigurationByName(const char *domain_name) const 
     137{ 
     138  assert(domain_name); 
     139 
     140  if (!*domain_name) 
     141  { 
     142    return *this; 
     143  } 
     144 
     145  const char *p = std::strchr(domain_name, '.'); 
     146  if (p) 
     147  { 
     148    return this->LookupChild(domain_name, p - domain_name).GetConfigurationByName(p + 1); 
     149  } 
     150 
     151  return this->LookupChild(domain_name, std::strlen(domain_name)); 
     152} 
     153 
     154//---------------------------------------------------------------------- 
     155// tConfiguration GetConfigurationByFilename 
     156//---------------------------------------------------------------------- 
     157const tConfiguration &tConfiguration::GetConfigurationByFilename(const char *filename) const 
     158{ 
     159  assert(filename); 
     160 
     161  // Return directly if filename does not contain any folders (leaf) 
     162  const char *p = std::strchr(filename, '/'); 
     163  if (!p) 
     164  { 
     165    return *this; 
     166  } 
     167 
     168  return this->LookupChild(filename, p - filename).GetConfigurationByFilename(p + 1); 
     169} 
     170 
     171const tConfiguration &tConfiguration::LookupChild(const char *name, size_t length) const 
     172{ 
     173  tConfiguration *configuration = 0; 
     174  auto insertion_point = this->children.end(); 
     175 
     176  // Iterate over sorted list of children (must be sorted longest name first to work) 
     177  for (auto it = this->children.begin(); it != this->children.end(); ++it) 
     178  { 
     179    const size_t current_length = (*it)->Name().length(); 
     180 
     181    // Skip too long names 
     182    if (current_length > length) 
     183    { 
     184      continue; 
     185    } 
     186 
     187    // Compare matching names 
     188    if (current_length == length) 
     189    { 
     190      if (std::strncmp(name, (*it)->Name().c_str(), length) == 0) 
     191      { 
     192        configuration = *it; 
     193        break; 
     194      } 
     195    } 
     196 
     197    // Shorter names start -> insert new configuration before 
     198    insertion_point = it; 
     199    break; 
     200  } 
     201 
     202  if (!configuration) 
     203  { 
     204    configuration = new tConfiguration(this, std::string(name, length)); 
     205    this->children.insert(insertion_point, configuration); 
     206  } 
     207 
     208  return *configuration; 
     209} 
     210 
     211//---------------------------------------------------------------------- 
     212// End of namespace declaration 
     213//---------------------------------------------------------------------- 
     214} 
     215} 
  • configuration/tConfiguration.h

    r53 r68  
    2020// 
    2121//---------------------------------------------------------------------- 
    22 /*!\file    tLogDomainConfiguration.h 
     22/*!\file    tConfiguration.h 
    2323 * 
    2424 * \author  Tobias Foehst 
     
    2626 * \date    2010-06-20 
    2727 * 
    28  * \brief Contains tLogDomainConfiguration and corresponding enumerations eLogLevel, eLogStream, eLogStreamMask 
     28 * \brief Contains tConfiguration and corresponding enumerations eLogLevel, eLogStream, eLogStreamMask 
    2929 * 
    30  * \b tLogDomainConfiguration 
     30 * \b tConfiguration 
    3131 * 
    32  * tLogDomainConfiguration encapsulates the configuration of logging 
     32 * tConfiguration encapsulates the configuration of logging 
    3333 * domains in the RRLib logging facility. It therefore stores settings 
    3434 * like enabled output fields, max. message level, etc. 
     
    5555//---------------------------------------------------------------------- 
    5656#ifndef __rrlib__logging__include_guard__ 
    57 #error Invalid include directive. Try #include "rrlib/logging/definitions.h" instead. 
     57#error Invalid include directive. Try #include "rrlib/logging/configuration.h" instead. 
    5858#endif 
    5959 
    60 #ifndef __rrlib__logging__tLogDomainConfiguration_h__ 
    61 #define __rrlib__logging__tLogDomainConfiguration_h__ 
     60#ifndef __rrlib__logging__configuration__tConfiguration_h__ 
     61#define __rrlib__logging__configuration__tConfiguration_h__ 
    6262 
    6363//---------------------------------------------------------------------- 
     
    6565//---------------------------------------------------------------------- 
    6666#include <string> 
    67 #include <memory> 
     67#include <list> 
    6868 
    6969//---------------------------------------------------------------------- 
    7070// Internal includes with "" 
    7171//---------------------------------------------------------------------- 
     72#include "rrlib/logging/log_levels.h" 
    7273 
    7374//---------------------------------------------------------------------- 
     
    8687// Forward declarations / typedefs / enums 
    8788//---------------------------------------------------------------------- 
    88 //! Enumeration type that contains the available message levels 
    89 enum tLogLevel 
    90 { 
    91   eLL_USER,             //!< Information for user (including end-users). Is always shown. 
    92   eLL_ERROR,            //!< Error message. Used to inform about _certain_ malfunction of application. Is always shown. 
    93   eLL_WARNING,          //!< Critical warning. Warns about possible application malfunction and invalid (and therefore discarded) user input. (default max level with _RRLIB_LOGGING_LESS_OUTPUT_) 
    94   eLL_DEBUG_WARNING,    //!< Debug info with warning character (e.g. "Parameter x not set - using default y") 
    95   eLL_DEBUG,            //!< Debug info about coarse program flow (default max level without _RRLIB_LOGGING_LESS_OUTPUT_) - information possibly relevant to developers outside of respective domain 
    96   eLL_DEBUG_VERBOSE_1,  //!< Higher detail debug info (not available in release mode) - only relevant to developers in respective domain 
    97   eLL_DEBUG_VERBOSE_2,  //!< Higher detail debug info (not available in release mode) - only relevant to developers in respective domain 
    98   eLL_DEBUG_VERBOSE_3,  //!< Higher detail debug info (not available in release mode) - only relevant to developers in respective domain 
    99   eLL_DIMENSION         //!< Endmarker and dimension of eLogLevel 
    100 }; 
    10189 
    10290 
     
    123111 * 
    124112 */ 
    125 class tLogDomainConfiguration 
     113class tConfiguration 
    126114{ 
    127   friend class tLogDomainRegistry; 
    128   friend class tLogDomain; 
     115  friend class tLogDomainRegistryImplementation; 
     116 
     117//---------------------------------------------------------------------- 
     118// Public methods and typedefs 
     119//---------------------------------------------------------------------- 
     120public: 
     121 
     122  ~tConfiguration(); 
     123 
     124  inline const std::string &Name() const 
     125  { 
     126    return this->name; 
     127  } 
     128 
     129  inline const std::string GetFullQualifiedName() const 
     130  { 
     131    return (this->parent && this->parent->parent ? this->parent->GetFullQualifiedName() : "") + "." + this->Name(); 
     132  } 
     133 
     134  inline bool PrintsTime() const 
     135  { 
     136    return this->prints_time; 
     137  } 
     138 
     139  inline bool PrintsName() const 
     140  { 
     141    return this->prints_name; 
     142  } 
     143 
     144  inline bool PrintsLevel() const 
     145  { 
     146    return this->prints_level; 
     147  } 
     148 
     149  inline bool PrintsLocation() const 
     150  { 
     151    return this->prints_location; 
     152  } 
     153 
     154  inline const tLogLevel MaxMessageLevel() const 
     155  { 
     156    return this->max_message_level; 
     157  } 
     158 
     159  const tConfiguration &GetConfigurationByName(const char *domain_name) const; 
    129160 
    130161//---------------------------------------------------------------------- 
     
    133164private: 
    134165 
     166  const tConfiguration *parent; 
    135167  std::string name; 
    136   bool configure_sub_tree; 
    137168 
    138   bool print_time; 
    139   bool print_name; 
    140   bool print_level; 
    141   bool print_location; 
     169  bool prints_time; 
     170  bool prints_name; 
     171  bool prints_level; 
     172  bool prints_location; 
     173 
    142174  tLogLevel max_message_level; 
    143   int sink_mask; 
     175//  int sink_mask; 
    144176 
    145   explicit tLogDomainConfiguration(const std::string &name); 
     177  mutable std::list<tConfiguration *> children; 
    146178 
    147   tLogDomainConfiguration(const tLogDomainConfiguration &other); 
     179  tConfiguration(const tConfiguration *parent, const std::string &name); 
    148180 
    149   tLogDomainConfiguration &operator = (const tLogDomainConfiguration other); 
     181  tConfiguration(const tConfiguration &other); 
     182  tConfiguration &operator = (const tConfiguration other); 
     183 
     184  const tConfiguration &GetConfigurationByFilename(const char *filename) const; 
     185 
     186  const tConfiguration &LookupChild(const char *name, size_t length) const; 
    150187 
    151188}; 
    152  
    153 //! Shared pointer to instances of tLogDomainConfiguration 
    154 typedef std::shared_ptr<tLogDomainConfiguration> tLogDomainConfigurationSharedPointer; 
    155189 
    156190//---------------------------------------------------------------------- 
  • configuration/tLogDomainRegistry.cpp

    r53 r68  
    2929//---------------------------------------------------------------------- 
    3030#define __rrlib__logging__include_guard__ 
    31 #include "rrlib/logging/tLogDomainRegistry.h" 
     31#include "rrlib/logging/configuration/tLogDomainRegistry.h" 
    3232 
    3333//---------------------------------------------------------------------- 
     
    3939#endif 
    4040 
     41#include <algorithm> 
     42#include <cstring> 
     43#include <sstream> 
     44 
     45#include <iostream> 
     46 
    4147//---------------------------------------------------------------------- 
    4248// Internal includes with "" 
    4349//---------------------------------------------------------------------- 
    44 #include "rrlib/logging/tLogDomain.h" 
    4550 
    4651//---------------------------------------------------------------------- 
     
    5156// Namespace usage 
    5257//---------------------------------------------------------------------- 
    53 using namespace rrlib::logging; 
    54  
    5558#ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
    5659using namespace rrlib::xml2; 
     
    5861 
    5962//---------------------------------------------------------------------- 
     63// Namespace declaration 
     64//---------------------------------------------------------------------- 
     65namespace rrlib 
     66{ 
     67namespace logging 
     68{ 
     69 
     70//---------------------------------------------------------------------- 
    6071// Forward declarations / typedefs / enums 
    6172//---------------------------------------------------------------------- 
     
    7081 
    7182//---------------------------------------------------------------------- 
    72 // tLogDomainRegistry constructors 
    73 //---------------------------------------------------------------------- 
    74 tLogDomainRegistry::tLogDomainRegistry() 
    75     : max_domain_name_length(0), 
    76     pad_prefix_columns(true), 
    77     pad_multi_line_messages(true) 
     83// tLogDomainRegistryImplementation constructors 
     84//---------------------------------------------------------------------- 
     85tLogDomainRegistryImplementation::tLogDomainRegistryImplementation() 
     86    : global_configuration(new tConfiguration(0, "")) 
     87//    : max_domain_name_length(0), 
     88//    pad_prefix_columns(true), 
     89//    pad_multi_line_messages(true) 
    7890{ 
    79   this->domain_configurations.push_back(tLogDomainConfigurationSharedPointer(new tLogDomainConfiguration("."))); 
    80   this->domains.push_back(std::shared_ptr<tLogDomain>(new tLogDomain(this->domain_configurations.back()))); 
     91  // Create a string literal from the value of RRLIB_LOG_PATH and let p point to its beginning 
     92#define __RRLIB_LOG_QUOTE_MACRO__(x) #x 
     93#define __RRLIB_LOG_MAKE_STRING__(macro) __RRLIB_LOG_QUOTE_MACRO__(macro) 
     94  const char *p = __RRLIB_LOG_MAKE_STRING__(RRLIB_LOG_PATH); 
     95#undef __RRLIB_LOG_MAKE_STRING__ 
     96#undef __RRLIB_LOG_QUOTE_MACRO__ 
     97 
     98  // Fill a list of pointers to the components of our immutable RRLIB_LOG_PATH literal (no zero termination) 
     99  this->prefix_pointers.push_back(p); 
     100  while (*p) 
     101  { 
     102    if (*p == ':') 
     103    { 
     104      this->prefix_pointers.push_back(p + 1); 
     105    } 
     106    ++p; 
     107  } 
     108  this->prefix_pointers.push_back(p + 1); 
     109 
     110  // From the list of pointer calculate the component sizes and a lookup table for sorted access (longest-first) 
     111  for (size_t i = 0; i < this->prefix_pointers.size() - 1; ++i) 
     112  { 
     113    this->prefix_lengths.push_back(this->prefix_pointers[i + 1] - this->prefix_pointers[i] - 1); 
     114    this->prefix_indices_sorted_by_length.push_back(i); 
     115  } 
     116  std::sort(this->prefix_indices_sorted_by_length.begin(), this->prefix_indices_sorted_by_length.end(), 
     117            [this](size_t a, size_t b) 
     118  { 
     119    return this->prefix_lengths[a] > this->prefix_lengths[b]; 
     120  }); 
     121 
     122//  for (auto it = this->prefix_indices_sorted_by_length.begin(); it != this->prefix_indices_sorted_by_length.end(); ++it) 
     123//  { 
     124//    std::cout << *it << " -> " << this->prefix_lengths[*it] << std::endl; 
     125//  } 
     126 
     127 
     128//  this->domain_configurations.push_back(tConfigurationSharedPointer(new tConfiguration("."))); 
     129//  this->domains.push_back(std::shared_ptr<tLogDomain>(new tLogDomain(this->domain_configurations.back()))); 
    81130} 
    82131 
    83132//---------------------------------------------------------------------- 
    84 // tLogDomainRegistry GetInstance 
    85 //---------------------------------------------------------------------- 
    86 std::shared_ptr<tLogDomainRegistry> tLogDomainRegistry::GetInstance() 
     133// tLogDomainRegistryImplementation destructor 
     134//---------------------------------------------------------------------- 
     135tLogDomainRegistryImplementation::~tLogDomainRegistryImplementation() 
    87136{ 
    88   static std::shared_ptr<tLogDomainRegistry> instance(new tLogDomainRegistry()); 
    89   return instance; 
     137  delete this->global_configuration; 
    90138} 
    91139 
    92140//---------------------------------------------------------------------- 
    93 // tLogDomainRegistry GetSubDomain 
    94 //---------------------------------------------------------------------- 
    95 tLogDomainSharedPointer tLogDomainRegistry::GetSubDomain(const std::string &name, tLogDomainSharedPointer parent) 
     141// tLogDomainRegistryImplementation GetConfigurationByFilename 
     142//---------------------------------------------------------------------- 
     143const tConfiguration &tLogDomainRegistryImplementation::GetConfigurationByFilename(const char *filename) const 
    96144{ 
    97   assert(name.length() > 0); 
    98   assert(parent != tLogDomainSharedPointer()); 
    99   const std::string full_qualified_domain_name(parent->GetName() + (parent->parent ? "." : "") + name); 
    100   size_t i = this->GetDomainIndexByName(full_qualified_domain_name); 
    101   if (i == this->domains.size()) 
     145  bool found_prefix = false; 
     146 
     147  // Iterate over sorted list of RRLIB_LOG_PATH components 
     148  for (auto it = this->prefix_indices_sorted_by_length.begin(); it != this->prefix_indices_sorted_by_length.end(); ++it) 
    102149  { 
    103     tLogDomainConfigurationSharedPointer configuration(this->GetConfigurationByName(full_qualified_domain_name)); 
    104     this->domains.push_back(std::shared_ptr<tLogDomain>(new tLogDomain(configuration, *const_cast<tLogDomain *>(parent.get())))); 
    105     return this->domains.back(); 
    106   } 
    107   return this->domains[i]; 
    108 } 
    109  
    110 //---------------------------------------------------------------------- 
    111 // tLogDomainRegistry SetDomainConfiguresSubTree 
    112 //---------------------------------------------------------------------- 
    113 void tLogDomainRegistry::SetDomainConfiguresSubTree(const std::string &name, bool value) 
    114 { 
    115   tLogDomainConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
    116   configuration->configure_sub_tree = value; 
    117   this->PropagateDomainConfigurationToChildren(name); 
    118 } 
    119  
    120 //---------------------------------------------------------------------- 
    121 // tLogDomainRegistry SetDomainPrintsTime 
    122 //---------------------------------------------------------------------- 
    123 void tLogDomainRegistry::SetDomainPrintsTime(const std::string &name, bool value) 
    124 { 
    125   tLogDomainConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
    126   configuration->print_time = value; 
    127   this->PropagateDomainConfigurationToChildren(name); 
    128 } 
    129  
    130 //---------------------------------------------------------------------- 
    131 // tLogDomainRegistry SetDomainPrintsName 
    132 //---------------------------------------------------------------------- 
    133 void tLogDomainRegistry::SetDomainPrintsName(const std::string &name, bool value) 
    134 { 
    135   tLogDomainConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
    136   configuration->print_name = value; 
    137   this->PropagateDomainConfigurationToChildren(name); 
    138 } 
    139  
    140 //---------------------------------------------------------------------- 
    141 // tLogDomainRegistry SetDomainPrintsLevel 
    142 //---------------------------------------------------------------------- 
    143 void tLogDomainRegistry::SetDomainPrintsLevel(const std::string &name, bool value) 
    144 { 
    145   tLogDomainConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
    146   configuration->print_level = value; 
    147   this->PropagateDomainConfigurationToChildren(name); 
    148 } 
    149  
    150 //---------------------------------------------------------------------- 
    151 // tLogDomainRegistry SetDomainPrintsLocation 
    152 //---------------------------------------------------------------------- 
    153 void tLogDomainRegistry::SetDomainPrintsLocation(const std::string &name, bool value) 
    154 { 
    155   tLogDomainConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
    156   configuration->print_location = value; 
    157   this->PropagateDomainConfigurationToChildren(name); 
    158 } 
    159  
    160 //---------------------------------------------------------------------- 
    161 // tLogDomainRegistry SetDomainMaxMessageLevel 
    162 //---------------------------------------------------------------------- 
    163 void tLogDomainRegistry::SetDomainMaxMessageLevel(const std::string &name, tLogLevel value) 
    164 { 
    165   tLogLevel effective_value = std::max(value, eLL_ERROR); 
    166  
    167 #ifdef _RRLIB_LOGGING_LESS_OUTPUT_ 
    168   effective_value = std::min(value, eLL_DEBUG); 
    169 #endif 
    170  
    171   tLogDomainConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
    172   configuration->max_message_level = effective_value; 
    173   this->PropagateDomainConfigurationToChildren(name); 
    174 } 
    175  
    176 //---------------------------------------------------------------------- 
    177 // tLogDomainRegistry SetDomainSink 
    178 //---------------------------------------------------------------------- 
    179 void tLogDomainRegistry::SetDomainSink(const std::string &name, tLogSink sink_1, tLogSink sink_2, tLogSink sink_3, tLogSink sink_4) 
    180 { 
    181   int mask = 0; 
    182   mask |= (sink_1 != eLS_DIMENSION) ? (1 << sink_1) : 0; 
    183   mask |= (sink_2 != eLS_DIMENSION) ? (1 << sink_2) : 0; 
    184   mask |= (sink_3 != eLS_DIMENSION) ? (1 << sink_3) : 0; 
    185   mask |= (sink_4 != eLS_DIMENSION) ? (1 << sink_4) : 0; 
    186   this->SetDomainSinkMask(name, mask); 
    187 } 
    188  
    189 //---------------------------------------------------------------------- 
    190 // tLogDomainRegistry SetDomainSinkMask 
    191 //---------------------------------------------------------------------- 
    192 void tLogDomainRegistry::SetDomainSinkMask(const std::string &name, int mask) 
    193 { 
    194   tLogDomainConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
    195   configuration->sink_mask = mask; 
    196   this->PropagateDomainConfigurationToChildren(name); 
    197 } 
    198  
    199 //---------------------------------------------------------------------- 
    200 // tLogDomainRegistry GetDomainIndexByName 
    201 //---------------------------------------------------------------------- 
    202 const size_t tLogDomainRegistry::GetDomainIndexByName(const std::string &name) const 
    203 { 
    204   for (size_t i = 0; i < this->domains.size(); ++i) 
    205   { 
    206     if (this->domains[i]->GetName() == name) 
     150    const size_t length = this->prefix_lengths[*it]; 
     151 
     152    // Skip if prefix length does not fit to path structure 
     153    if (filename[length] != '/') 
    207154    { 
    208       return i; 
     155      continue; 
     156    } 
     157 
     158    // Due to the longest-first sorted list the first match terminates our search 
     159    if (length > 0 && std::strncmp(filename, this->prefix_pointers[*it], length) == 0) 
     160    { 
     161      filename = filename + length + 1; 
     162      found_prefix = true; 
     163      break; 
    209164    } 
    210165  } 
    211   return this->domains.size(); 
     166 
     167  if (!found_prefix && this->prefix_lengths[this->prefix_indices_sorted_by_length.back()] > 0) 
     168  { 
     169    std::stringstream message; 
     170    message << "'" << filename << "' is not in RRLIB_LOG_PATH"; 
     171    throw std::runtime_error(message.str()); 
     172  } 
     173 
     174  assert(this->global_configuration); 
     175  return this->global_configuration->GetConfigurationByFilename(filename); 
    212176} 
    213177 
    214 //---------------------------------------------------------------------- 
    215 // tLogDomainRegistry GetConfigurationByName 
    216 //---------------------------------------------------------------------- 
    217 tLogDomainConfigurationSharedPointer tLogDomainRegistry::GetConfigurationByName(const std::string &name) 
    218 { 
    219   for (std::vector<tLogDomainConfigurationSharedPointer>::iterator it = this->domain_configurations.begin(); it != this->domain_configurations.end(); ++it) 
    220   { 
    221     if ((*it)->name == name) 
    222     { 
    223       return *it; 
    224     } 
    225   } 
    226   this->domain_configurations.push_back(tLogDomainConfigurationSharedPointer(new tLogDomainConfiguration(name))); 
    227   this->max_domain_name_length = std::max(this->max_domain_name_length, name.length()); 
    228   return this->domain_configurations.back(); 
     178////---------------------------------------------------------------------- 
     179//// tLogDomainRegistry GetSubDomain 
     180////---------------------------------------------------------------------- 
     181//tLogDomainSharedPointer tLogDomainRegistry::GetSubDomain(const std::string &name, tLogDomainSharedPointer parent) 
     182//{ 
     183//  assert(name.length() > 0); 
     184//  assert(parent != tLogDomainSharedPointer()); 
     185//  const std::string full_qualified_domain_name(parent->GetName() + (parent->parent ? "." : "") + name); 
     186//  size_t i = this->GetDomainIndexByName(full_qualified_domain_name); 
     187//  if (i == this->domains.size()) 
     188//  { 
     189//    tConfigurationSharedPointer configuration(this->GetConfigurationByName(full_qualified_domain_name)); 
     190//    this->domains.push_back(std::shared_ptr<tLogDomain>(new tLogDomain(configuration, *const_cast<tLogDomain *>(parent.get())))); 
     191//    return this->domains.back(); 
     192//  } 
     193//  return this->domains[i]; 
     194//} 
     195// 
     196////---------------------------------------------------------------------- 
     197//// tLogDomainRegistry SetDomainConfiguresSubTree 
     198////---------------------------------------------------------------------- 
     199//void tLogDomainRegistry::SetDomainConfiguresSubTree(const std::string &name, bool value) 
     200//{ 
     201//  tConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
     202//  configuration->configure_sub_tree = value; 
     203//  this->PropagateDomainConfigurationToChildren(name); 
     204//} 
     205// 
     206////---------------------------------------------------------------------- 
     207//// tLogDomainRegistry SetDomainPrintsTime 
     208////---------------------------------------------------------------------- 
     209//void tLogDomainRegistry::SetDomainPrintsTime(const std::string &name, bool value) 
     210//{ 
     211//  tConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
     212//  configuration->print_time = value; 
     213//  this->PropagateDomainConfigurationToChildren(name); 
     214//} 
     215// 
     216////---------------------------------------------------------------------- 
     217//// tLogDomainRegistry SetDomainPrintsName 
     218////---------------------------------------------------------------------- 
     219//void tLogDomainRegistry::SetDomainPrintsName(const std::string &name, bool value) 
     220//{ 
     221//  tConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
     222//  configuration->print_name = value; 
     223//  this->PropagateDomainConfigurationToChildren(name); 
     224//} 
     225// 
     226////---------------------------------------------------------------------- 
     227//// tLogDomainRegistry SetDomainPrintsLevel 
     228////---------------------------------------------------------------------- 
     229//void tLogDomainRegistry::SetDomainPrintsLevel(const std::string &name, bool value) 
     230//{ 
     231//  tConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
     232//  configuration->print_level = value; 
     233//  this->PropagateDomainConfigurationToChildren(name); 
     234//} 
     235// 
     236////---------------------------------------------------------------------- 
     237//// tLogDomainRegistry SetDomainPrintsLocation 
     238////---------------------------------------------------------------------- 
     239//void tLogDomainRegistry::SetDomainPrintsLocation(const std::string &name, bool value) 
     240//{ 
     241//  tConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
     242//  configuration->print_location = value; 
     243//  this->PropagateDomainConfigurationToChildren(name); 
     244//} 
     245// 
     246////---------------------------------------------------------------------- 
     247//// tLogDomainRegistry SetDomainMaxMessageLevel 
     248////---------------------------------------------------------------------- 
     249//void tLogDomainRegistry::SetDomainMaxMessageLevel(const std::string &name, tLogLevel value) 
     250//{ 
     251//  tLogLevel effective_value = std::max(value, eLL_ERROR); 
     252// 
     253//#ifdef _RRLIB_LOGGING_LESS_OUTPUT_ 
     254//  effective_value = std::min(value, eLL_DEBUG); 
     255//#endif 
     256// 
     257//  tConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
     258//  configuration->max_message_level = effective_value; 
     259//  this->PropagateDomainConfigurationToChildren(name); 
     260//} 
     261// 
     262////---------------------------------------------------------------------- 
     263//// tLogDomainRegistry SetDomainSink 
     264////---------------------------------------------------------------------- 
     265//void tLogDomainRegistry::SetDomainSink(const std::string &name, tLogSink sink_1, tLogSink sink_2, tLogSink sink_3, tLogSink sink_4) 
     266//{ 
     267//  int mask = 0; 
     268//  mask |= (sink_1 != eLS_DIMENSION) ? (1 << sink_1) : 0; 
     269//  mask |= (sink_2 != eLS_DIMENSION) ? (1 << sink_2) : 0; 
     270//  mask |= (sink_3 != eLS_DIMENSION) ? (1 << sink_3) : 0; 
     271//  mask |= (sink_4 != eLS_DIMENSION) ? (1 << sink_4) : 0; 
     272//  this->SetDomainSinkMask(name, mask); 
     273//} 
     274// 
     275////---------------------------------------------------------------------- 
     276//// tLogDomainRegistry SetDomainSinkMask 
     277////---------------------------------------------------------------------- 
     278//void tLogDomainRegistry::SetDomainSinkMask(const std::string &name, int mask) 
     279//{ 
     280//  tConfigurationSharedPointer configuration(this->GetConfigurationByName(name)); 
     281//  configuration->sink_mask = mask; 
     282//  this->PropagateDomainConfigurationToChildren(name); 
     283//} 
     284// 
     285////---------------------------------------------------------------------- 
     286//// tLogDomainRegistry GetDomainIndexByName 
     287////---------------------------------------------------------------------- 
     288//const size_t tLogDomainRegistry::GetDomainIndexByName(const std::string &name) const 
     289//{ 
     290//  for (size_t i = 0; i < this->domains.size(); ++i) 
     291//  { 
     292//    if (this->domains[i]->GetName() == name) 
     293//    { 
     294//      return i; 
     295//    } 
     296//  } 
     297//  return this->domains.size(); 
     298//} 
     299// 
     300////---------------------------------------------------------------------- 
     301//// tLogDomainRegistry GetConfigurationByName 
     302////---------------------------------------------------------------------- 
     303//tConfigurationSharedPointer tLogDomainRegistry::GetConfigurationByName(const std::string &name) 
     304//{ 
     305//  for (std::vector<tConfigurationSharedPointer>::iterator it = this->domain_configurations.begin(); it != this->domain_configurations.end(); ++it) 
     306//  { 
     307//    if ((*it)->name == name) 
     308//    { 
     309//      return *it; 
     310//    } 
     311//  } 
     312//  this->domain_configurations.push_back(tConfigurationSharedPointer(new tConfiguration(name))); 
     313//  this->max_domain_name_length = std::max(this->max_domain_name_length, name.length()); 
     314//  return this->domain_configurations.back(); 
     315//} 
     316// 
     317////---------------------------------------------------------------------- 
     318//// tLogDomainRegistry PropagateDomainConfigurationToChildren 
     319////---------------------------------------------------------------------- 
     320//void tLogDomainRegistry::PropagateDomainConfigurationToChildren(const std::string &name) 
     321//{ 
     322//  size_t i = this->GetDomainIndexByName(name); 
     323//  if (i != this->domains.size()) 
     324//  { 
     325//    for (std::vector<tLogDomain *>::iterator it = this->domains[i]->children.begin(); it != this->domains[i]->children.end(); ++it) 
     326//    { 
     327//      (*it)->ConfigureSubTree(); 
     328//    } 
     329//  } 
     330//} 
     331// 
     332////---------------------------------------------------------------------- 
     333//// tLogDomainRegistry ConfigureFromFile 
     334////---------------------------------------------------------------------- 
     335//bool tLogDomainRegistry::ConfigureFromFile(const std::string &file_name) 
     336//{ 
     337//#ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
     338//  try 
     339//  { 
     340//    tXMLDocument document(file_name); 
     341//    return this->ConfigureFromXMLNode(document.GetRootNode()); 
     342//  } 
     343//  catch (const tXML2WrapperException &e) 
     344//  { 
     345//    std::cerr << "RRLib Logging: tLogDomainRegistry::ConfigureFromFile >> " << e.what() << std::endl; 
     346//    return false; 
     347//  } 
     348//#else 
     349//  std::cerr << "RRLib Logging: tLogDomainRegistry::ConfigureFromFile >> XML support not available due to missing rrlib_mca2_wrapper." << std::endl; 
     350//  return false; 
     351//#endif 
     352//} 
     353// 
     354//#ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
     355// 
     356////---------------------------------------------------------------------- 
     357//// tLogDomainRegistry ConfigureFromXMLNode 
     358////---------------------------------------------------------------------- 
     359//bool tLogDomainRegistry::ConfigureFromXMLNode(const tXMLNode &node) 
     360//{ 
     361//  if (node.GetName() != "rrlib_logging") 
     362//  { 
     363//    std::cerr << "RRLib Logging: tLogDomainRegistry::ConfigureFromXMLNode >> Unexpected content (Not an rrlib_logging tree)" << std::endl; 
     364//    return false; 
     365//  } 
     366// 
     367//  try 
     368//  { 
     369//    if (node.HasAttribute("pad_prefix_columns")) 
     370//    { 
     371//      this->pad_prefix_columns = node.GetBoolAttribute("pad_prefix_columns"); 
     372//    } 
     373//    if (node.HasAttribute("pad_multi_line_messages")) 
     374//    { 
     375//      this->pad_multi_line_messages = node.GetBoolAttribute("pad_multi_line_messages"); 
     376//    } 
     377// 
     378//    for (tXMLNode::const_iterator it = node.GetChildrenBegin(); it != node.GetChildrenEnd(); ++it) 
     379//    { 
     380//      if (it->GetName() == "domain") 
     381//      { 
     382//        if (!this->AddConfigurationFromXMLNode(*it)) 
     383//        { 
     384//          return false; 
     385//        } 
     386//      } 
     387//    } 
     388//  } 
     389//  catch (const tXML2WrapperException &e) 
     390//  { 
     391//    std::cerr << "RRLib Logging: tLogDomainRegistry::ConfigureFromXMLNode >> " << e.what() << std::endl; 
     392//    return false; 
     393//  } 
     394// 
     395//  return true; 
     396//} 
     397// 
     398////---------------------------------------------------------------------- 
     399//// tLogDomainRegistry AddConfigurationFromXMLNode 
     400////---------------------------------------------------------------------- 
     401//bool tLogDomainRegistry::AddConfigurationFromXMLNode(const tXMLNode &node, const std::string &parent_name) 
     402//{ 
     403//  static const char *level_names_init[eLL_DIMENSION - eLL_ERROR] = { "error", "warning", "debug_warning", "debug", "debug_verbose_1", "debug_verbose_2", "debug_verbose_3" }; 
     404//  static const std::vector<std::string> level_names(level_names_init, level_names_init + eLL_DIMENSION - eLL_ERROR); 
     405//  // FIXME: with c++0x this can be static const std::vector<std::string> level_names = { "error", "warning", "debug_warning", "debug", "debug_verbose_1", "debug_verbose_2", "debug_verbose_3" }; 
     406// 
     407//  static const char *sink_names_init[eLS_DIMENSION] = { "stdout", "stderr", "file", "combined_file" }; 
     408//  static const std::vector<std::string> sink_names(sink_names_init, sink_names_init + eLS_DIMENSION); 
     409//  // FIXME: with c++0x this can be static const std::vector<std::string> stream_names = { "stdout", "stderr", "file", "combined_file" }; 
     410// 
     411//  assert(node.GetName() == "domain"); 
     412// 
     413//  const std::string prefix((parent_name == "." ? "" : parent_name) + "."); 
     414//  const std::string node_name(node.GetStringAttribute("name")); 
     415//  const std::string name(prefix + (!parent_name.length() && node_name == "global" ? "" : node_name)); 
     416// 
     417//  if (node.HasAttribute("configures_sub_tree")) 
     418//  { 
     419//    this->SetDomainConfiguresSubTree(name, node.GetBoolAttribute("configures_sub_tree")); 
     420//  } 
     421// 
     422//  if (node.HasAttribute("print_time")) 
     423//  { 
     424//    this->SetDomainPrintsTime(name, node.GetBoolAttribute("print_time")); 
     425//  } 
     426// 
     427//  if (node.HasAttribute("print_name")) 
     428//  { 
     429//    this->SetDomainPrintsName(name, node.GetBoolAttribute("print_name")); 
     430//  } 
     431// 
     432//  if (node.HasAttribute("print_level")) 
     433//  { 
     434//    this->SetDomainPrintsLevel(name, node.GetBoolAttribute("print_level")); 
     435//  } 
     436// 
     437//  if (node.HasAttribute("print_location")) 
     438//  { 
     439//    this->SetDomainPrintsLocation(name, node.GetBoolAttribute("print_location")); 
     440//  } 
     441// 
     442//  if (node.HasAttribute("max_level")) 
     443//  { 
     444//    this->SetDomainMaxMessageLevel(name, static_cast<tLogLevel>(eLL_ERROR + node.GetEnumAttribute<tLogLevel>("max_level", level_names))); 
     445//  } 
     446// 
     447//  bool sinks_configured = false; 
     448//  if (node.HasAttribute("sink")) 
     449//  { 
     450//    sinks_configured = true; 
     451//    this->SetDomainSink(name, node.GetEnumAttribute<tLogSink>("sink", sink_names)); 
     452//  } 
     453// 
     454//  int sink_mask = 0; 
     455//  for (tXMLNode::const_iterator it = node.GetChildrenBegin(); it != node.GetChildrenEnd(); ++it) 
     456//  { 
     457//    if (it->GetName() == "sink") 
     458//    { 
     459//      if (sinks_configured) 
     460//      { 
     461//        std::cerr << "RRLib Logging: tLogDomainRegistry::AddConfigurationFromXMLNode >> Sink already configured in domain element!" << std::endl; 
     462//        return false; 
     463//      } 
     464//      sink_mask |= 1 << it->GetEnumAttribute<tLogSink>("output", sink_names); 
     465//    } 
     466//  } 
     467//  if (sink_mask != 0) 
     468//  { 
     469//    this->SetDomainSinkMask(name, sink_mask); 
     470//  } 
     471// 
     472//  for (tXMLNode::const_iterator it = node.GetChildrenBegin(); it != node.GetChildrenEnd(); ++it) 
     473//  { 
     474//    if (it->GetName() == "domain") 
     475//    { 
     476//      if (!this->AddConfigurationFromXMLNode(*it, name)) 
     477//      { 
     478//        return false; 
     479//      } 
     480//    } 
     481//  } 
     482// 
     483//  return true; 
     484//} 
     485// 
     486//#endif 
     487 
     488//---------------------------------------------------------------------- 
     489// End of namespace declaration 
     490//---------------------------------------------------------------------- 
    229491} 
    230  
    231 //---------------------------------------------------------------------- 
    232 // tLogDomainRegistry PropagateDomainConfigurationToChildren 
    233 //---------------------------------------------------------------------- 
    234 void tLogDomainRegistry::PropagateDomainConfigurationToChildren(const std::string &name) 
    235 { 
    236   size_t i = this->GetDomainIndexByName(name); 
    237   if (i != this->domains.size()) 
    238   { 
    239     for (std::vector<tLogDomain *>::iterator it = this->domains[i]->children.begin(); it != this->domains[i]->children.end(); ++it) 
    240     { 
    241       (*it)->ConfigureSubTree(); 
    242     } 
    243   } 
    244492} 
    245  
    246 //---------------------------------------------------------------------- 
    247 // tLogDomainRegistry ConfigureFromFile 
    248 //---------------------------------------------------------------------- 
    249 bool tLogDomainRegistry::ConfigureFromFile(const std::string &file_name) 
    250 { 
    251 #ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
    252   try 
    253   { 
    254     tXMLDocument document(file_name); 
    255     return this->ConfigureFromXMLNode(document.GetRootNode()); 
    256   } 
    257   catch (const tXML2WrapperException &e) 
    258   { 
    259     std::cerr << "RRLib Logging: tLogDomainRegistry::ConfigureFromFile >> " << e.what() << std::endl; 
    260     return false; 
    261   } 
    262 #else 
    263   std::cerr << "RRLib Logging: tLogDomainRegistry::ConfigureFromFile >> XML support not available due to missing rrlib_mca2_wrapper." << std::endl; 
    264   return false; 
    265 #endif 
    266 } 
    267  
    268 #ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
    269  
    270 //---------------------------------------------------------------------- 
    271 // tLogDomainRegistry ConfigureFromXMLNode 
    272 //---------------------------------------------------------------------- 
    273 bool tLogDomainRegistry::ConfigureFromXMLNode(const tXMLNode &node) 
    274 { 
    275   if (node.GetName() != "rrlib_logging") 
    276   { 
    277     std::cerr << "RRLib Logging: tLogDomainRegistry::ConfigureFromXMLNode >> Unexpected content (Not an rrlib_logging tree)" << std::endl; 
    278     return false; 
    279   } 
    280  
    281   try 
    282   { 
    283     if (node.HasAttribute("pad_prefix_columns")) 
    284     { 
    285       this->pad_prefix_columns = node.GetBoolAttribute("pad_prefix_columns"); 
    286     } 
    287     if (node.HasAttribute("pad_multi_line_messages")) 
    288     { 
    289       this->pad_multi_line_messages = node.GetBoolAttribute("pad_multi_line_messages"); 
    290     } 
    291  
    292     for (tXMLNode::const_iterator it = node.GetChildrenBegin(); it != node.GetChildrenEnd(); ++it) 
    293     { 
    294       if (it->GetName() == "domain") 
    295       { 
    296         if (!this->AddConfigurationFromXMLNode(*it)) 
    297         { 
    298           return false; 
    299         } 
    300       } 
    301     } 
    302   } 
    303   catch (const tXML2WrapperException &e) 
    304   { 
    305     std::cerr << "RRLib Logging: tLogDomainRegistry::ConfigureFromXMLNode >> " << e.what() << std::endl; 
    306     return false; 
    307   } 
    308  
    309   return true; 
    310 } 
    311  
    312 //---------------------------------------------------------------------- 
    313 // tLogDomainRegistry AddConfigurationFromXMLNode 
    314 //---------------------------------------------------------------------- 
    315 bool tLogDomainRegistry::AddConfigurationFromXMLNode(const tXMLNode &node, const std::string &parent_name) 
    316 { 
    317   static const char *level_names_init[eLL_DIMENSION - eLL_ERROR] = { "error", "warning", "debug_warning", "debug", "debug_verbose_1", "debug_verbose_2", "debug_verbose_3" }; 
    318   static const std::vector<std::string> level_names(level_names_init, level_names_init + eLL_DIMENSION - eLL_ERROR); 
    319   // FIXME: with c++0x this can be static const std::vector<std::string> level_names = { "error", "warning", "debug_warning", "debug", "debug_verbose_1", "debug_verbose_2", "debug_verbose_3" }; 
    320  
    321   static const char *sink_names_init[eLS_DIMENSION] = { "stdout", "stderr", "file", "combined_file" }; 
    322   static const std::vector<std::string> sink_names(sink_names_init, sink_names_init + eLS_DIMENSION); 
    323   // FIXME: with c++0x this can be static const std::vector<std::string> stream_names = { "stdout", "stderr", "file", "combined_file" }; 
    324  
    325   assert(node.GetName() == "domain"); 
    326  
    327   const std::string prefix((parent_name == "." ? "" : parent_name) + "."); 
    328   const std::string node_name(node.GetStringAttribute("name")); 
    329   const std::string name(prefix + (!parent_name.length() && node_name == "global" ? "" : node_name)); 
    330  
    331   if (node.HasAttribute("configures_sub_tree")) 
    332   { 
    333     this->SetDomainConfiguresSubTree(name, node.GetBoolAttribute("configures_sub_tree")); 
    334   } 
    335  
    336   if (node.HasAttribute("print_time")) 
    337   { 
    338     this->SetDomainPrintsTime(name, node.GetBoolAttribute("print_time")); 
    339   } 
    340  
    341   if (node.HasAttribute("print_name")) 
    342   { 
    343     this->SetDomainPrintsName(name, node.GetBoolAttribute("print_name")); 
    344   } 
    345  
    346   if (node.HasAttribute("print_level")) 
    347   { 
    348     this->SetDomainPrintsLevel(name, node.GetBoolAttribute("print_level")); 
    349   } 
    350  
    351   if (node.HasAttribute("print_location")) 
    352   { 
    353     this->SetDomainPrintsLocation(name, node.GetBoolAttribute("print_location")); 
    354   } 
    355  
    356   if (node.HasAttribute("max_level")) 
    357   { 
    358     this->SetDomainMaxMessageLevel(name, static_cast<tLogLevel>(eLL_ERROR + node.GetEnumAttribute<tLogLevel>("max_level", level_names))); 
    359   } 
    360  
    361   bool sinks_configured = false; 
    362   if (node.HasAttribute("sink")) 
    363   { 
    364     sinks_configured = true; 
    365     this->SetDomainSink(name, node.GetEnumAttribute<tLogSink>("sink", sink_names)); 
    366   } 
    367  
    368   int sink_mask = 0; 
    369   for (tXMLNode::const_iterator it = node.GetChildrenBegin(); it != node.GetChildrenEnd(); ++it) 
    370   { 
    371     if (it->GetName() == "sink") 
    372     { 
    373       if (sinks_configured) 
    374       { 
    375         std::cerr << "RRLib Logging: tLogDomainRegistry::AddConfigurationFromXMLNode >> Sink already configured in domain element!" << std::endl; 
    376         return false; 
    377       } 
    378       sink_mask |= 1 << it->GetEnumAttribute<tLogSink>("output", sink_names); 
    379     } 
    380   } 
    381   if (sink_mask != 0) 
    382   { 
    383     this->SetDomainSinkMask(name, sink_mask); 
    384   } 
    385  
    386   for (tXMLNode::const_iterator it = node.GetChildrenBegin(); it != node.GetChildrenEnd(); ++it) 
    387   { 
    388     if (it->GetName() == "domain") 
    389     { 
    390       if (!this->AddConfigurationFromXMLNode(*it, name)) 
    391       { 
    392         return false; 
    393       } 
    394     } 
    395   } 
    396  
    397   return true; 
    398 } 
    399  
    400 #endif 
  • configuration/tLogDomainRegistry.h

    r53 r68  
    4242//---------------------------------------------------------------------- 
    4343#ifndef __rrlib__logging__include_guard__ 
    44 #error Invalid include directive. Try #include "rrlib/logging/definitions.h" instead. 
     44#error Invalid include directive. Try #include "rrlib/logging/configuration.h" instead. 
    4545#endif 
    4646 
    47 #ifndef __rrlib__logging__tLogDomainRegistry_h__ 
    48 #define __rrlib__logging__tLogDomainRegistry_h__ 
     47#ifndef RRLIB_LOG_PATH 
     48#warning RRLIB_LOG_PATH not set. Using default path "/usr/include:/usr/include/finroc" which most likely is not sufficient for your setup. 
     49#define RRLIB_LOG_PATH /usr/include:/usr/include/finroc 
     50#endif 
     51 
     52#ifndef __rrlib__logging__configuration__tLogDomainRegistry_h__ 
     53#define __rrlib__logging__configuration__tLogDomainRegistry_h__ 
    4954 
    5055//---------------------------------------------------------------------- 
    5156// External includes (system with <>, local with "") 
    5257//---------------------------------------------------------------------- 
     58//#include <string> 
    5359#include <vector> 
    54 #include <string> 
    55 #include <memory> 
     60 
     61#include "rrlib/util/patterns/singleton.h" 
    5662 
    5763#ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
    5864#include "rrlib/xml2_wrapper/tXMLNode.h" 
    5965#endif 
     66 
    6067//---------------------------------------------------------------------- 
    6168// Internal includes with "" 
    6269//---------------------------------------------------------------------- 
    63 #include "rrlib/logging/tLogDomain.h" 
    64 #include "rrlib/logging/tLogDomainConfiguration.h" 
     70#include "rrlib/logging/configuration/tConfiguration.h" 
    6571 
    6672//---------------------------------------------------------------------- 
     
    8692/*! In RRLib logging messages can be send via several logging domains. 
    8793 *  These have to be created and maintained using a single instance of 
    88  *  this class. Thus, this class implements the singleton pattern and 
    89  *  contains a list of active logging domains and configurations that 
    90  *  either were created along with active domains or were configured by 
    91  *  the user from a file or calling the appropriate methods. 
    92  * 
     94 *  this class. Thus, this class registers a list of active logging domains 
     95 *  and configurations that either were created along with active domains 
     96 *  or were configured by the user from a file or calling the appropriate 
     97 *  methods. 
     98 *  It must be used via the singleton holder typedef below. 
    9399 */ 
    94 class tLogDomainRegistry 
     100class tLogDomainRegistryImplementation 
    95101{ 
    96102 
     
    100106public: 
    101107 
    102   /*! Get an instance of this class (singleton) 
     108  /*! Ctor of tLogDomainRegistryImplementation 
    103109   * 
    104    * Due to the singleton pattern this class has no public constructor. 
    105    * The only way to get an object is to call this method. 
     110   */ 
     111  tLogDomainRegistryImplementation(); 
     112 
     113  /*! Dtor of tLogDomainRegistryImplementation 
    106114   * 
    107    * \returns The only instance of this class that should exist 
    108115   */ 
    109   static std::shared_ptr<tLogDomainRegistry> GetInstance(); 
    110  
    111   /*! Get the default domain 
    112    * 
    113    * There is always on default domain registered that can be accessed 
    114    * using this method as a shortcut. 
    115    * 
    116    * \returns The default domain object 
    117    */ 
    118   static inline tLogDomainSharedPointer GetDefaultDomain() 
     116  ~tLogDomainRegistryImplementation(); 
     117 
     118  inline const tConfiguration &GetGlobalConfiguration() const 
    119119  { 
    120     return GetInstance()->domains[0]; 
     120    assert(this->global_configuration); 
     121    return *this->global_configuration; 
    121122  } 
    122123 
    123   /*! Get a subdomain with given name and parent. 
    124    * 
    125    * This method can be used to access a subdomain of the given parent 
    126    * with given name. It then implements the lookup and if the domain 
    127    * was not found creates a new one and applies an eventually existing 
    128    * configuration. 
    129    * 
    130    * \param name     The name of the subdomain (local part) 
    131    * \param parent   The parent of the subdomain 
    132    * 
    133    * \returns The found or newly created domain object as a shared pointer 
    134    */ 
    135   tLogDomainSharedPointer GetSubDomain(const std::string &name, tLogDomainSharedPointer parent); 
    136  
    137   /*! Set a prefix for filenames that are created as log 
    138    * 
    139    * If their output stream is set to eMS_FILE domains create a log 
    140    * file with their name. Additionally, this name must have a prefix 
    141    * to distinguish between programs, processes or runs. 
    142    * 
    143    * The method could be called with basename(argv[0]) in main, for example. 
    144    * 
    145    * \param file_name_prefix   The string the should be used as prefix 
    146    */ 
    147   inline void SetOutputFileNamePrefix(const std::string &file_name_prefix) 
    148   { 
    149     assert(file_name_prefix.length() > 0); 
    150     this->file_name_prefix = file_name_prefix; 
    151   } 
    152  
    153   /*! Get the configured file name prefix 
    154    * 
    155    * Get the file name prefix that was configured 
    156    * 
    157    * \returns The stored prefix 
    158    */ 
    159   inline const std::string &GetOutputFileNamePrefix() const 
    160   { 
    161     return this->file_name_prefix; 
    162   } 
    163  
    164   /*! Set if columns in prefix output should be padded or not 
    165    * 
    166    * If the prefix output columns should be aligned, the fields for the 
    167    * domain name and message level are padded with spaces to the right. 
    168    * 
    169    * \param value   The new value of this flag 
    170    */ 
    171   inline void SetPadPrefixColumns(bool value) 
    172   { 
    173     this->pad_prefix_columns = value; 
    174   } 
    175  
    176   /*! Get if columns in prefix output should be padded or not 
    177    * 
    178    * If the prefix output columns should be aligned, the fields for the 
    179    * domain name and message level are padded with spaces to the right. 
    180    * 
    181    * \returns Whether the columns in prefix output should be padded or not 
    182    */ 
    183   inline const bool GetPadPrefixColumns() const 
    184   { 
    185     return this->pad_prefix_columns; 
    186   } 
    187  
    188   /*! Set if rows in output should be padded to start after the prefix or not 
    189    * 
    190    * For multiline output following line do not have a prefix. Thus, they start 
    191    * in the first column whearas the first row started right after the prefix. 
    192    * This flag allows to choose if subsequent lines should be padded to match the 
    193    * first row or not. 
    194    * 
    195    * \param value   The new value of this flag 
    196    */ 
    197   inline void SetPadMultiLineMessages(bool value) 
    198   { 
    199     this->pad_multi_line_messages = value; 
    200   } 
    201  
    202   /*! Get if rows in output should be padded to start after the prefix or not 
    203    * 
    204    * For multiline output following line do not have a prefix. Thus, they start 
    205    * in the first column whearas the first row started right after the prefix. 
    206    * This flag allows to choose if subsequent lines should be padded to match the 
    207    * first row or not. 
    208    * 
    209    * \returns Whether the rows should be padded or not 
    210    */ 
    211   inline const bool GetPadMultiLineMessages() const 
    212   { 
    213     return this->pad_multi_line_messages; 
    214   } 
    215  
    216   /*! Get the length of the longest full qualified domain name 
    217    * 
    218    * This method can be used for formatting user dialogs 
    219    * 
    220    * \returns The length of the longest domain name 
    221    */ 
    222   std::string::size_type GetMaxDomainNameLength() const 
    223   { 
    224     return this->max_domain_name_length; 
    225   } 
    226  
    227   /*! Set if the domain configures its subtree or not 
    228    * 
    229    * If set to true every configuration update to the given domain 
    230    * will be propagated to its subtree. 
    231    * 
    232    * \param name    The full qualified name of the domain 
    233    * \param value   The new value of the setting 
    234    */ 
    235   void SetDomainConfiguresSubTree(const std::string &name, bool value); 
    236  
    237   /*! Set if the domain should prepend the current time to each message 
    238    * 
    239    * If set to true every message will start with the current time 
    240    * 
    241    * \param name    The full qualified name of the domain 
    242    * \param value   The new value of the setting 
    243    */ 
    244   void SetDomainPrintsTime(const std::string &name, bool value); 
    245  
    246   /*! Set if the domain should prepend messages with its name 
    247    * 
    248    * If set to true every message will include the full qualified domain 
    249    * name 
    250    * 
    251    * \param name    The full qualified name of the domain 
    252    * \param value   The new value of the setting 
    253    */ 
    254   void SetDomainPrintsName(const std::string &name, bool value); 
    255  
    256   /*! Set if the domain should prepend messages with their level 
    257    * 
    258    * If set to true every message will include its level 
    259    * 
    260    * \param name    The full qualified name of the domain 
    261    * \param value   The new value of the setting 
    262    */ 
    263   void SetDomainPrintsLevel(const std::string &name, bool value); 
    264  
    265   /*! Set if the domain should prepend the message with its location 
    266    * 
    267    * If set to true every message will include its location in code. 
    268    * This is extremely helpful during debugging phases. 
    269    * 
    270    * \param name    The full qualified name of the domain 
    271    * \param value   The new value of the setting 
    272    */ 
    273   void SetDomainPrintsLocation(const std::string &name, bool value); 
    274  
    275   /*! Set the maximal message level of the given domain 
    276    * 
    277    * The output of each message that has a level above the given value 
    278    * will be suppressed. Default is eML_DEBUG or eML_WARNING depending on 
    279    * compile flags. 
    280    * 
    281    * \param name    The full qualified name of the domain 
    282    * \param value   The new value of the setting 
    283    */ 
    284   void SetDomainMaxMessageLevel(const std::string &name, tLogLevel value); 
    285  
    286   /*! Set the output streams that should be used as sink by the given domain 
    287    * 
    288    * \param name     The full qualified name of the domain 
    289    * \param sink_1   The first sink to be used by the given domain 
    290    * \param sink_2   The second sink to be used by the given domain 
    291    * \param sink_3   The third sink to be used by the given domain 
    292    * \param sink_4   The fourth sink to be used by the given domain 
    293    */ 
    294   void SetDomainSink(const std::string &name, tLogSink sink_1, tLogSink sink_2 = eLS_DIMENSION, tLogSink sink_3 = eLS_DIMENSION, tLogSink sink_4 = eLS_DIMENSION); 
    295  
    296   /*! Read domain configuration from a given XML file 
    297    * 
    298    * The overall configuration of the logging domains tends to be 
    299    * too complicated for a classical command line option interface. 
    300    * Therefore, it is possible to specify the configuration in form 
    301    * of an XML file following the DTD -//RRLIB//logging 
    302    * 
    303    * \param file_name   The XML file to be read 
    304    * 
    305    * \returns Whether the configuration could be read and applied or not 
    306    */ 
    307   bool ConfigureFromFile(const std::string &file_name); 
    308  
    309 #ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
    310   /*! Read domain configuration from a given XML node 
    311    * 
    312    * Instead of reading and parsing an XML file dedicated to configure 
    313    * logging domains this method can be used after externally parsing 
    314    * a document that contains an rrlib_logging node following the DTD 
    315    * -//RRLIB//logging 
    316    * 
    317    * \param node   The XML node containing the configuration 
    318    * 
    319    * \returns Whether the configuration could be applied or not 
    320    */ 
    321   bool ConfigureFromXMLNode(const xml2::tXMLNode &node); 
    322 #endif 
     124  const tConfiguration &GetConfigurationByFilename(const char *filename) const; 
     125 
     126//  /*! Get a subdomain with given name and parent. 
     127//   * 
     128//   * This method can be used to access a subdomain of the given parent 
     129//   * with given name. It then implements the lookup and if the domain 
     130//   * was not found creates a new one and applies an eventually existing 
     131//   * configuration. 
     132//   * 
     133//   * \param name     The name of the subdomain (local part) 
     134//   * \param parent   The parent of the subdomain 
     135//   * 
     136//   * \returns The found or newly created domain object as a shared pointer 
     137//   */ 
     138//  tLogDomainSharedPointer GetSubDomain(const std::string &name, tLogDomainSharedPointer parent); 
     139 
     140//  /*! Set a prefix for filenames that are created as log 
     141//   * 
     142//   * If their output stream is set to eMS_FILE domains create a log 
     143//   * file with their name. Additionally, this name must have a prefix 
     144//   * to distinguish between programs, processes or runs. 
     145//   * 
     146//   * The method could be called with basename(argv[0]) in main, for example. 
     147//   * 
     148//   * \param file_name_prefix   The string that should be used as prefix 
     149//   */ 
     150//  inline void SetOutputFileNamePrefix(const std::string &file_name_prefix) 
     151//  { 
     152//    assert(file_name_prefix.length() > 0); 
     153//    this->file_name_prefix = file_name_prefix; 
     154//  } 
     155// 
     156//  /*! Get the configured file name prefix 
     157//   * 
     158//   * Get the file name prefix that was configured 
     159//   * 
     160//   * \returns The stored prefix 
     161//   */ 
     162//  inline const std::string &GetOutputFileNamePrefix() const 
     163//  { 
     164//    return this->file_name_prefix; 
     165//  } 
     166// 
     167//  /*! Set if columns in prefix output should be padded or not 
     168//   * 
     169//   * If the prefix output columns should be aligned, the fields for the 
     170//   * domain name and message level are padded with spaces to the right. 
     171//   * 
     172//   * \param value   The new value of this flag 
     173//   */ 
     174//  inline void SetPadPrefixColumns(bool value) 
     175//  { 
     176//    this->pad_prefix_columns = value; 
     177//  } 
     178// 
     179//  /*! Get if columns in prefix output should be padded or not 
     180//   * 
     181//   * If the prefix output columns should be aligned, the fields for the 
     182//   * domain name and message level are padded with spaces to the right. 
     183//   * 
     184//   * \returns Whether the columns in prefix output should be padded or not 
     185//   */ 
     186//  inline const bool GetPadPrefixColumns() const 
     187//  { 
     188//    return this->pad_prefix_columns; 
     189//  } 
     190// 
     191//  /*! Set if rows in output should be padded to start after the prefix or not 
     192//   * 
     193//   * For multiline output following line do not have a prefix. Thus, they start 
     194//   * in the first column whearas the first row started right after the prefix. 
     195//   * This flag allows to choose if subsequent lines should be padded to match the 
     196//   * first row or not. 
     197//   * 
     198//   * \param value   The new value of this flag 
     199//   */ 
     200//  inline void SetPadMultiLineMessages(bool value) 
     201//  { 
     202//    this->pad_multi_line_messages = value; 
     203//  } 
     204// 
     205//  /*! Get if rows in output should be padded to start after the prefix or not 
     206//   * 
     207//   * For multiline output following line do not have a prefix. Thus, they start 
     208//   * in the first column whearas the first row started right after the prefix. 
     209//   * This flag allows to choose if subsequent lines should be padded to match the 
     210//   * first row or not. 
     211//   * 
     212//   * \returns Whether the rows should be padded or not 
     213//   */ 
     214//  inline const bool GetPadMultiLineMessages() const 
     215//  { 
     216//    return this->pad_multi_line_messages; 
     217//  } 
     218// 
     219//  /*! Get the length of the longest full qualified domain name 
     220//   * 
     221//   * This method can be used for formatting user dialogs 
     222//   * 
     223//   * \returns The length of the longest domain name 
     224//   */ 
     225//  std::string::size_type GetMaxDomainNameLength() const 
     226//  { 
     227//    return this->max_domain_name_length; 
     228//  } 
     229// 
     230//  /*! Set if the domain configures its subtree or not 
     231//   * 
     232//   * If set to true every configuration update to the given domain 
     233//   * will be propagated to its subtree. 
     234//   * 
     235//   * \param name    The full qualified name of the domain 
     236//   * \param value   The new value of the setting 
     237//   */ 
     238//  void SetDomainConfiguresSubTree(const std::string &name, bool value); 
     239// 
     240//  /*! Set if the domain should prepend the current time to each message 
     241//   * 
     242//   * If set to true every message will start with the current time 
     243//   * 
     244//   * \param name    The full qualified name of the domain 
     245//   * \param value   The new value of the setting 
     246//   */ 
     247//  void SetDomainPrintsTime(const std::string &name, bool value); 
     248// 
     249//  /*! Set if the domain should prepend messages with its name 
     250//   * 
     251//   * If set to true every message will include the full qualified domain 
     252//   * name 
     253//   * 
     254//   * \param name    The full qualified name of the domain 
     255//   * \param value   The new value of the setting 
     256//   */ 
     257//  void SetDomainPrintsName(const std::string &name, bool value); 
     258// 
     259//  /*! Set if the domain should prepend messages with their level 
     260//   * 
     261//   * If set to true every message will include its level 
     262//   * 
     263//   * \param name    The full qualified name of the domain 
     264//   * \param value   The new value of the setting 
     265//   */ 
     266//  void SetDomainPrintsLevel(const std::string &name, bool value); 
     267// 
     268//  /*! Set if the domain should prepend the message with its location 
     269//   * 
     270//   * If set to true every message will include its location in code. 
     271//   * This is extremely helpful during debugging phases. 
     272//   * 
     273//   * \param name    The full qualified name of the domain 
     274//   * \param value   The new value of the setting 
     275//   */ 
     276//  void SetDomainPrintsLocation(const std::string &name, bool value); 
     277// 
     278//  /*! Set the maximal message level of the given domain 
     279//   * 
     280//   * The output of each message that has a level above the given value 
     281//   * will be suppressed. Default is eML_DEBUG or eML_WARNING depending on 
     282//   * compile flags. 
     283//   * 
     284//   * \param name    The full qualified name of the domain 
     285//   * \param value   The new value of the setting 
     286//   */ 
     287//  void SetDomainMaxMessageLevel(const std::string &name, tLogLevel value); 
     288// 
     289//  /*! Set the output streams that should be used as sink by the given domain 
     290//   * 
     291//   * \param name     The full qualified name of the domain 
     292//   * \param sink_1   The first sink to be used by the given domain 
     293//   * \param sink_2   The second sink to be used by the given domain 
     294//   * \param sink_3   The third sink to be used by the given domain 
     295//   * \param sink_4   The fourth sink to be used by the given domain 
     296//   */ 
     297//  void SetDomainSink(const std::string &name, tLogSink sink_1, tLogSink sink_2 = eLS_DIMENSION, tLogSink sink_3 = eLS_DIMENSION, tLogSink sink_4 = eLS_DIMENSION); 
     298// 
     299//  /*! Read domain configuration from a given XML file 
     300//   * 
     301//   * The overall configuration of the logging domains tends to be 
     302//   * too complicated for a classical command line option interface. 
     303//   * Therefore, it is possible to specify the configuration in form 
     304//   * of an XML file following the DTD -//RRLIB//logging 
     305//   * 
     306//   * \param file_name   The XML file to be read 
     307//   * 
     308//   * \returns Whether the configuration could be read and applied or not 
     309//   */ 
     310//  bool ConfigureFromFile(const std::string &file_name); 
     311// 
     312//#ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
     313//  /*! Read domain configuration from a given XML node 
     314//   * 
     315//   * Instead of reading and parsing an XML file dedicated to configure 
     316//   * logging domains this method can be used after externally parsing 
     317//   * a document that contains an rrlib_logging node following the DTD 
     318//   * -//RRLIB//logging 
     319//   * 
     320//   * \param node   The XML node containing the configuration 
     321//   * 
     322//   * \returns Whether the configuration could be applied or not 
     323//   */ 
     324//  bool ConfigureFromXMLNode(const xml2::tXMLNode &node); 
     325//#endif 
    323326 
    324327//---------------------------------------------------------------------- 
     
    327330private: 
    328331 
    329   std::string file_name_prefix; 
    330   std::vector<std::shared_ptr<tLogDomain> > domains; 
    331   std::vector<tLogDomainConfigurationSharedPointer> domain_configurations; 
    332   std::string::size_type max_domain_name_length; 
    333   bool pad_prefix_columns; 
    334   bool pad_multi_line_messages; 
    335  
    336   /*! Ctor of tLogDomainRegistry 
    337    * 
    338    * Private default ctor for singleton pattern 
    339    */ 
    340   tLogDomainRegistry(); 
    341  
    342   /*! Get the index of the domain with the given name 
    343    * 
    344    * Helper method that implements the lookup for existing domains 
    345    * 
    346    * \param name   The name of the wanted domain 
    347    * 
    348    * \returns The index of the domain if found. If not, the methods returns the size of the domain vector. 
    349    */ 
    350   const size_t GetDomainIndexByName(const std::string &name) const; 
    351  
    352   /*! Get a configuration object for a domain with the given name 
    353    * 
    354    * This methods implements the lookup for existing domain names and 
    355    * creates a new configuration object for new names. 
    356    * 
    357    * \param name   The name of the domain to be configured 
    358    * 
    359    * \returns The wanted domain configuration as a shared pointer 
    360    */ 
    361   tLogDomainConfigurationSharedPointer GetConfigurationByName(const std::string &name); 
    362  
    363   /*! Update configuration the subtree of a domain for recursion 
    364    * 
    365    * If the configuration of one domain is changed start update of its 
    366    * subtree. This method should always be called because the decision 
    367    * about recursive configuration is done within its call. 
    368    * That keeps update methods simpler. 
    369    * 
    370    * \param name   The name of the updated domain 
    371    */ 
    372   void PropagateDomainConfigurationToChildren(const std::string &name); 
    373  
    374   /*! Set the output streams that should be used by the given domain 
    375    * 
    376    * \param name   The full qualified name of the domain 
    377    * \param mask   The mask that represents the streams to be used as sink 
    378    */ 
    379   void SetDomainSinkMask(const std::string &name, int mask); 
    380  
    381 #ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
    382   /*! Add a domain configuration from a given XML node 
    383    * 
    384    * This method configures a logging domain using the values specified in 
    385    * the given XML node. It also implements recursive configuration in case 
    386    * of nested nodes. 
    387    * 
    388    * \param node          The XML node that contains the configuration 
    389    * \param parent_name   For recursive calls the current domain name is build from parent_name and domain_name 
    390    * 
    391    * \returns Whether the domain was successfully configured or not 
    392    */ 
    393   bool AddConfigurationFromXMLNode(const xml2::tXMLNode &node, const std::string &parent_name = ""); 
    394 #endif 
     332  std::vector<const char *> prefix_pointers; 
     333  std::vector<size_t> prefix_lengths; 
     334  std::vector<size_t> prefix_indices_sorted_by_length; 
     335 
     336  mutable tConfiguration *global_configuration; 
     337 
     338//  std::string file_name_prefix; 
     339//  std::vector<std::shared_ptr<tLogDomain> > domains; 
     340//  std::vector<tConfigurationSharedPointer> domain_configurations; 
     341//  std::string::size_type max_domain_name_length; 
     342//  bool pad_prefix_columns; 
     343//  bool pad_multi_line_messages; 
     344// 
     345//  /*! Get the index of the domain with the given name 
     346//   * 
     347//   * Helper method that implements the lookup for existing domains 
     348//   * 
     349//   * \param name   The name of the wanted domain 
     350//   * 
     351//   * \returns The index of the domain if found. If not, the methods returns the size of the domain vector. 
     352//   */ 
     353//  const size_t GetDomainIndexByName(const std::string &name) const; 
     354// 
     355//  /*! Get a configuration object for a domain with the given name 
     356//   * 
     357//   * This methods implements the lookup for existing domain names and 
     358//   * creates a new configuration object for new names. 
     359//   * 
     360//   * \param name   The name of the domain to be configured 
     361//   * 
     362//   * \returns The wanted domain configuration as a shared pointer 
     363//   */ 
     364//  tConfigurationSharedPointer GetConfigurationByName(const std::string &name); 
     365// 
     366//  /*! Update configuration the subtree of a domain for recursion 
     367//   * 
     368//   * If the configuration of one domain is changed start update of its 
     369//   * subtree. This method should always be called because the decision 
     370//   * about recursive configuration is done within its call. 
     371//   * That keeps update methods simpler. 
     372//   * 
     373//   * \param name   The name of the updated domain 
     374//   */ 
     375//  void PropagateDomainConfigurationToChildren(const std::string &name); 
     376// 
     377//  /*! Set the output streams that should be used by the given domain 
     378//   * 
     379//   * \param name   The full qualified name of the domain 
     380//   * \param mask   The mask that represents the streams to be used as sink 
     381//   */ 
     382//  void SetDomainSinkMask(const std::string &name, int mask); 
     383// 
     384//#ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
     385//  /*! Add a domain configuration from a given XML node 
     386//   * 
     387//   * This method configures a logging domain using the values specified in 
     388//   * the given XML node. It also implements recursive configuration in case 
     389//   * of nested nodes. 
     390//   * 
     391//   * \param node          The XML node that contains the configuration 
     392//   * \param parent_name   For recursive calls the current domain name is build from parent_name and domain_name 
     393//   * 
     394//   * \returns Whether the domain was successfully configured or not 
     395//   */ 
     396//  bool AddConfigurationFromXMLNode(const xml2::tXMLNode &node, const std::string &parent_name = ""); 
     397//#endif 
    395398 
    396399}; 
     400 
     401typedef util::tSingletonHolder<tLogDomainRegistryImplementation, util::singleton::CreateUsingNew, util::singleton::NoDestruction> tLogDomainRegistry; 
    397402 
    398403//---------------------------------------------------------------------- 
  • default_log_description.cpp

    r38 r68  
    2020// 
    2121//---------------------------------------------------------------------- 
    22 /*!\file    definitions.cpp 
     22/*!\file    default_log_description.cpp 
    2323 * 
    2424 * \author  Tobias Foehst 
     
    2828 */ 
    2929//---------------------------------------------------------------------- 
    30 #include "rrlib/logging/definitions.h" 
    3130 
    3231//---------------------------------------------------------------------- 
     
    5857//---------------------------------------------------------------------- 
    5958 
    60 char *rrlib::logging::default_log_description = const_cast<char *>("<Log description not defined>"); 
     59namespace rrlib 
     60{ 
     61namespace logging 
     62{ 
     63char *default_log_description = const_cast<char *>("<Log description not defined>"); 
     64} 
     65} 
  • make.xml

    r58 r68  
    44 
    55  <rrlib name="logging" 
    6         libs="boost boost_thread"> 
     6        libs="boost_thread"> 
    77    <sources> 
    8       *.cpp 
     8      configuration/*.cpp 
     9      messages/*.cpp 
     10      messages.h 
     11      log_levels.h 
     12      default_log_description.cpp 
    913    </sources> 
    1014  </rrlib> 
     
    1620  </testprogram> 
    1721 
    18   <testprogram name="logging"> 
    19     <sources> 
    20       test/test_logging.cpp 
    21     </sources> 
    22   </testprogram> 
    23  
    2422</targets> 
  • messages.h

    r64 r68  
    2020// 
    2121//---------------------------------------------------------------------- 
    22 /*!\file    definitions.h 
     22/*!\file    messages.h 
    2323 * 
    2424 * \author  Tobias Foehst 
    25  * \author  Max Reichardt 
    2625 * 
    2726 * \date    2010-06-16 
     
    2928 * \brief Contains macro definitions for using the RRLib logging framework 
    3029 * 
    31  * \b Creating Domains 
    32  * 
    33  * A few words for definitions.h 
    34  * 
    3530 * \b Log Messages 
    3631 * 
    37  * A few words for definitions.h 
    38  * 
    39  */ 
    40 //---------------------------------------------------------------------- 
    41 #ifndef __rrlib__logging__definitions_h__ 
    42 #define __rrlib__logging__definitions_h__ 
     32 * A few words for messages.h 
     33 * 
     34 */ 
     35//---------------------------------------------------------------------- 
     36#ifndef __rrlib__logging__messages_h__ 
     37#define __rrlib__logging__messages_h__ 
    4338 
    4439//---------------------------------------------------------------------- 
     
    5146#define __rrlib__logging__include_guard__ 
    5247 
    53 #include "rrlib/logging/tLogDomain.h" 
    54 #include "rrlib/logging/tLogDomainRegistry.h" 
     48#include "rrlib/logging/log_levels.h" 
     49#include "rrlib/logging/messages/implementation.h" 
    5550 
    5651#undef __rrlib__logging__include_guard__ 
     
    5954// Namespace declaration 
    6055//---------------------------------------------------------------------- 
    61 namespace rrlib 
    62 { 
    63 namespace logging 
    64 { 
    65  
    66 //---------------------------------------------------------------------- 
    67 // Implementation 
    68 //---------------------------------------------------------------------- 
    69 //! The default description for global debugging. Can be set to whatever string the user like to set it to 
    70 extern char *default_log_description; 
    71  
    72 template <typename ... Types> 
    73 inline rrlib::logging::tLogDomainSharedPointer GetLogDomain(rrlib::logging::tLogDomainSharedPointer(&default_domain)(), const Types &...) 
    74 { 
    75   return default_domain(); 
    76 } 
    77 inline rrlib::logging::tLogDomainSharedPointer GetLogDomain(rrlib::logging::tLogDomainSharedPointer(&default_domain)(), rrlib::logging::tLogDomainSharedPointer(&named_domain)()) 
    78 { 
    79   return named_domain(); 
    80 } 
    81  
    82 //---------------------------------------------------------------------- 
    83 // End of namespace declaration 
    84 //---------------------------------------------------------------------- 
    85 } 
    86 } 
    87  
    88 //---------------------------------------------------------------------- 
    89 // Implementation of the global logging domain 
    90 //---------------------------------------------------------------------- 
    91 // The default global scoped logging domain 
    92 inline rrlib::logging::tLogDomainSharedPointer default_log() 
    93 { 
    94   return rrlib::logging::tLogDomainRegistry::GetDefaultDomain(); 
    95 } 
     56// The macro interface and defaul GetLogDescription function must live 
     57// within the global namespace 
     58 
     59//---------------------------------------------------------------------- 
     60// Forward declarations / typedefs / enums 
     61//---------------------------------------------------------------------- 
     62 
     63//---------------------------------------------------------------------- 
     64// Macros for internal use 
     65//---------------------------------------------------------------------- 
     66#define __RRLIB_LOG_PRINT__(domain, level, args...) \ 
     67  rrlib::logging::Print(domain, GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level, args); 
     68 
     69#define __RRLIB_LOG_PRINT_STATIC__(domain, level, args...) \ 
     70  rrlib::logging::Print(domain, "<static>", __FUNCTION__, __FILE__, __LINE__, level, args); 
     71 
     72#define __RRLIB_LOG_PRINTF__(domain, level, args...) \ 
     73  rrlib::logging::PrintFormatted(domain, GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level, args); 
     74 
     75#define __RRLIB_LOG_PRINTF_STATIC__(domain, level, args...) \ 
     76  rrlib::logging::PrintFormatted(domain, "<static>", __FUNCTION__, __FILE__, __LINE__, level, args); 
     77 
     78//---------------------------------------------------------------------- 
     79// The macro interface to the logging library 
     80//---------------------------------------------------------------------- 
     81#ifdef _RRLIB_LOGGING_LESS_OUTPUT_ 
     82 
     83/*! Macro to print messages using stream semantics 
     84 * 
     85 * \param level    The level of the message 
     86 * \param args     The data to be put into the underlying stream 
     87 */ 
     88#define RRLIB_LOG_PRINT(level, args...) \ 
     89  do \ 
     90  { \ 
     91    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     92    { \ 
     93      __RRLIB_LOG_PRINT__(rrlib::logging::GetConfiguration(__FILE__), level, args) \ 
     94    } \ 
     95  } while (0) \ 
     96      
     97/*! Macro to print messages to explicitly specified domain using stream semantics 
     98 * 
     99 * \param level    The level of the message 
     100 * \param domain   The domain the message should be printed to 
     101 * \param args     The data to be put into the underlying stream 
     102 */ 
     103#define RRLIB_LOG_PRINT(level, domain_name, args...) \ 
     104  do \ 
     105  { \ 
     106    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     107    { \ 
     108      __RRLIB_LOG_PRINT__(rrlib::logging::GetConfiguration(__FILE__, domain_name), level, args) \ 
     109    } \ 
     110  } while (0) \ 
     111      
     112/*! Macro to print messages using stream semantics from static context 
     113 * 
     114 * \param level    The level of the message 
     115 * \param args     The data to be put into the underlying stream 
     116 */ 
     117#define RRLIB_LOG_PRINT_STATIC(level, args...) \ 
     118  do \ 
     119  { \ 
     120    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     121    { \ 
     122      __RRLIB_LOG_PRINT_STATIC__(rrlib::logging::GetConfiguration(__FILE__), level, args) \ 
     123    } \ 
     124  } while (0) \ 
     125      
     126/*! Macro to print messages to explicitly specified domain using stream semantics from static context 
     127 * 
     128 * \param level    The level of the message 
     129 * \param domain   The domain the message should be printed to 
     130 * \param args     The data to be put into the underlying stream 
     131 */ 
     132#define RRLIB_LOG_PRINT_STATIC(level, domain_name, args...) \ 
     133  do \ 
     134  { \ 
     135    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     136    { \ 
     137      __RRLIB_LOG_PRINT_STATIC__(rrlib::logging::GetConfiguration(__FILE__, domain_name), level, args) \ 
     138    } \ 
     139  } while (0) \ 
     140      
     141/*! Macro to print messages using printf semantics 
     142 * 
     143 * \param level    The level of the message 
     144 * \param args     The format string for printf and the optional arguments to be printed 
     145 */ 
     146#define RRLIB_LOG_PRINTF(level, args...) \ 
     147  do \ 
     148  { \ 
     149    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     150    { \ 
     151      __RRLIB_LOG_PRINTF__(rrlib::logging::GetConfiguration(__FILE__), level, args) \ 
     152    } \ 
     153  } while (0) \ 
     154      
     155/*! Macro to print messages to explicitly specified domain using printf semantics 
     156 * 
     157 * \param level    The level of the message 
     158 * \param domain   The domain the message should be printed to 
     159 * \param args     The format string for printf and the optional arguments to be printed 
     160 */ 
     161#define RRLIB_LOG_PRINTF(level, domain_name, args...) \ 
     162  do \ 
     163  { \ 
     164    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     165    { \ 
     166      __RRLIB_LOG_PRINTF__(rrlib::logging::GetConfiguration(__FILE__, domain_name), level, args) \ 
     167    } \ 
     168  } while (0) \ 
     169      
     170/*! Macro to print messages using printf semantics from static context 
     171 * 
     172 * \param level    The level of the message 
     173 * \param args     The format string for printf and the optional arguments to be printed 
     174 */ 
     175#define RRLIB_LOG_PRINTF_STATIC(level, args...) \ 
     176  do \ 
     177  { \ 
     178    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     179    { \ 
     180      __RRLIB_LOG_PRINTF_STATIC__(rrlib::logging::GetConfiguration(__FILE__), level, args) \ 
     181    } \ 
     182  } while (0) \ 
     183      
     184/*! Macro to print messages to explicitly specified domain using printf semantics from static context 
     185 * 
     186 * \param level    The level of the message 
     187 * \param domain   The domain the message should be printed to 
     188 * \param args     The format string for printf and the optional arguments to be printed 
     189 */ 
     190#define RRLIB_LOG_PRINTF_STATIC(level, domain_name, args...) \ 
     191  do \ 
     192  { \ 
     193    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     194    { \ 
     195      __RRLIB_LOG_PRINTF_STATIC__(rrlib::logging::GetConfiguration(__FILE__, domain_name), level, args) \ 
     196    } \ 
     197  } while (0) \ 
     198      
     199#else 
     200 
     201/*! Macro to print messages using stream semantics 
     202 * 
     203 * \param level    The level of the message 
     204 * \param args     The data to be put into the underlying stream 
     205 */ 
     206#define RRLIB_LOG_PRINT(level, args...) \ 
     207  __RRLIB_LOG_PRINT__(rrlib::logging::GetConfiguration(__FILE__), level, args) \ 
     208    
     209/*! Macro to print messages to explicitly specified domain using stream semantics 
     210 * 
     211 * \param level    The level of the message 
     212 * \param domain   The domain the message should be printed to 
     213 * \param args     The data to be put into the underlying stream 
     214 */ 
     215#define RRLIB_LOG_PRINT_EXPLICIT(level, domain_name, args...) \ 
     216  __RRLIB_LOG_PRINT__(rrlib::logging::GetConfiguration(__FILE__, domain_name), level, args) \ 
     217    
     218/*! Macro to print messages using stream semantics static context 
     219 * 
     220 * \param level    The level of the message 
     221 * \param args     The data to be put into the underlying stream 
     222 */ 
     223#define RRLIB_LOG_PRINT_STATIC(level, args...) \ 
     224  __RRLIB_LOG_PRINT_STATIC__(rrlib::logging::GetConfiguration(__FILE__), level, args) \ 
     225    
     226/*! Macro to print messages to explicitly specified using stream semantics static context 
     227 * 
     228 * \param level    The level of the message 
     229 * \param domain   The domain the message should be printed to 
     230 * \param args     The data to be put into the underlying stream 
     231 */ 
     232#define RRLIB_LOG_PRINT_STATIC_EXPLICIT(level, domain_name, args...) \ 
     233  __RRLIB_LOG_PRINT_STATIC__(rrlib::logging::GetConfiguration(__FILE__, domain_name), level, args) \ 
     234    
     235/*! Macro to print messages using printf semantics 
     236 * 
     237 * \param level    The level of the message 
     238 * \param args     The format string for printf and the optional arguments to be printed 
     239 */ 
     240#define RRLIB_LOG_PRINTF(level, args...) \ 
     241  __RRLIB_LOG_PRINTF__(rrlib::logging::GetConfiguration(__FILE__), level, args) \ 
     242    
     243/*! Macro to print messages to explicitly specified using printf semantics 
     244 * 
     245 * \param level    The level of the message 
     246 * \param domain   The domain the message should be printed to 
     247 * \param args     The format string for printf and the optional arguments to be printed 
     248 */ 
     249#define RRLIB_LOG_PRINTF_EXPLICIT(level, domain_name, args...) \ 
     250  __RRLIB_LOG_PRINTF__(rrlib::logging::GetConfiguration(__FILE__, domain_name), level, args) \ 
     251    
     252/*! Macro to print messages using printf semantics from static context 
     253 * 
     254 * \param level    The level of the message 
     255 * \param args     The format string for printf and the optional arguments to be printed 
     256 */ 
     257#define RRLIB_LOG_PRINTF_STATIC(level, args...) \ 
     258  __RRLIB_LOG_PRINTF_STATIC__(rrlib::logging::GetConfiguration(__FILE__), level, args) \ 
     259    
     260/*! Macro to print messages to explicitly specified using printf semantics from static context 
     261 * 
     262 * \param level    The level of the message 
     263 * \param domain   The domain the message should be printed to 
     264 * \param args     The format string for printf and the optional arguments to be printed 
     265 */ 
     266#define RRLIB_LOG_PRINTF_STATIC_EXPLICIT(level, domain_name, args...) \ 
     267  __RRLIB_LOG_PRINTF_STATIC__(rrlib::logging::GetConfiguration(__FILE__, domain_name), level, args) \ 
     268    
     269#endif 
     270 
     271 
    96272 
    97273// The default global GetLogDescription definition 
     
    101277} 
    102278 
    103 //---------------------------------------------------------------------- 
    104 // Macros for internal use 
    105 //---------------------------------------------------------------------- 
    106 #define RRLIB_DEFAULT_LOG_DOMAIN_NAME default_log 
    107  
    108 #define RRLIB_LOG_GET_DOMAIN_I(domain...) \ 
    109   rrlib::logging::GetLogDomain(RRLIB_DEFAULT_LOG_DOMAIN_NAME, ## domain) \ 
    110  
    111 #define RRLIB_LOG_GET_DOMAIN(domain, args...) \ 
    112   RRLIB_LOG_GET_DOMAIN_I(domain) 
    113  
    114 #define RRLIB_LOG_STREAM_CALL(level, args...) \ 
    115   ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel() ? RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args) : RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level)) \ 
    116  
    117 #define RRLIB_LOG_STREAM_CALL_STATIC(level, args...) \ 
    118   ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel() ? RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream("<static>", __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args) : RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream("<static>", __FUNCTION__, __FILE__, __LINE__, level)) \ 
    119  
    120 #define RRLIB_LOG_PRINT_CALL(level, args...) \ 
    121   do \ 
    122   { \ 
    123     if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
    124     { \ 
    125       RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args); \ 
    126     } \ 
    127   } while (0) \ 
    128  
    129 #define RRLIB_LOG_PRINT_CALL_STATIC(level, args...) \ 
    130   do \ 
    131   { \ 
    132     if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
    133     { \ 
    134       RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream("<static>", __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args); \ 
    135     } \ 
    136   } while (0) \ 
    137  
    138 #define RRLIB_LOG_PRINTF_CALL(level, args...) \ 
    139   do \ 
    140   { \ 
    141     if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
    142     { \ 
    143       RRLIB_LOG_GET_DOMAIN(args)->PrintMessage(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level, args); \ 
    144     } \ 
    145   } while (0) \ 
    146  
    147 #define RRLIB_LOG_PRINTF_CALL_STATIC(level, args...) \ 
    148   do \ 
    149   { \ 
    150     if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
    151     { \ 
    152       RRLIB_LOG_GET_DOMAIN(args)->PrintMessage("<static>", __FUNCTION__, __FILE__, __LINE__, level, args); \ 
    153     } \ 
    154   } while (0) \ 
    155  
    156 //---------------------------------------------------------------------- 
    157 // The macro interface to the logging library 
    158 //---------------------------------------------------------------------- 
    159 #ifdef _RRLIB_LOGGING_LESS_OUTPUT_ 
    160  
    161 /*! Macro to get a stream for messages using operator << 
    162  * 
    163  * \param level    The level of the message 
    164  * \param domain   The domain the message should be processed in 
    165  * 
    166  * \returns The stream for message output 
    167  */ 
    168 #define RRLIB_LOG_STREAM(level, args...) \ 
    169   RRLIB_LOG_STREAM_CALL(level, args) \ 
    170  
    171 #define RRLIB_LOG_PRINT(level, args...) \ 
    172     do \ 
    173     { \ 
    174       if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    175       { \ 
    176         RRLIB_LOG_PRINT_CALL(level, args); \ 
    177       } \ 
    178     } while (0) \ 
    179  
    180 /*! Macro to get a stream for messages using operator << from static context 
    181  * 
    182  * \param level    The level of the message 
    183  * \param domain   The domain the message should be processed in 
    184  * 
    185  * \returns The stream for message output 
    186  */ 
    187 #define RRLIB_LOG_STREAM_STATIC(level, args...) \ 
    188   RRLIB_LOG_STREAM_CALL_STATIC(level, args) \ 
    189  
    190 #define RRLIB_LOG_PRINT_STATIC(level, args...) \ 
    191     do \ 
    192     { \ 
    193       if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    194       { \ 
    195         RRLIB_LOG_PRINT_CALL_STATIC(level, args); \ 
    196       } \ 
    197     } while (0) \ 
    198  
    199 /*! Macro for messages using printf syntax 
    200  * 
    201  * \param level    The level of the message 
    202  * \param domain   The domain the message should be processed in 
    203  * \param args     The format string for printf and the optional arguments to be printed. 
    204  */ 
    205 #define RRLIB_LOG_MESSAGE(level, args...) \ 
    206   do \ 
    207   { \ 
    208     if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    209     { \ 
    210       RRLIB_LOG_PRINTF_CALL(level, args); \ 
    211     } \ 
    212   } while (0) \ 
    213  
    214 #define RRLIB_LOG_PRINTF(level, args...) \ 
    215   do \ 
    216   { \ 
    217     if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    218     { \ 
    219       RRLIB_LOG_PRINTF_CALL(level, args); \ 
    220     } \ 
    221   } while (0) \ 
    222  
    223 /*! Macro for messages using printf syntax from static context 
    224  * 
    225  * \param level    The level of the message 
    226  * \param domain   The domain the message should be processed in 
    227  * \param args     The format string for printf and the optional arguments to be printed. 
    228  */ 
    229 #define RRLIB_LOG_MESSAGE_STATIC(level, args...) \ 
    230   do \ 
    231   { \ 
    232     if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    233     { \ 
    234       RRLIB_LOG_PRINTF_CALL_STATIC(level, args); \ 
    235     } \ 
    236   } while (0) \ 
    237  
    238 #define RRLIB_LOG_PRINTF_STATIC(level, args...) \ 
    239   do \ 
    240   { \ 
    241     if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    242     { \ 
    243       RRLIB_LOG_PRINTF_CALL_STATIC(level, args); \ 
    244     } \ 
    245   } while (0) \ 
    246  
    247 #else 
    248  
    249 /*! Macro to get a stream for messages using operator << 
    250  * 
    251  * \param level    The level of the message 
    252  * \param domain   The domain the message should be processed in 
    253  * 
    254  * \returns The stream for message output 
    255  */ 
    256 #define RRLIB_LOG_STREAM(level, args...) \ 
    257   RRLIB_LOG_STREAM_CALL(level, args) \ 
    258  
    259 #define RRLIB_LOG_PRINT(level, args...) \ 
    260   RRLIB_LOG_PRINT_CALL(level, args) \ 
    261  
    262 /*! Macro to get a stream for messages using operator << from static context 
    263  * 
    264  * \param level    The level of the message 
    265  * \param domain   The domain the message should be processed in 
    266  * 
    267  * \returns The stream for message output 
    268  */ 
    269 #define RRLIB_LOG_STREAM_STATIC(level, args...) \ 
    270   RRLIB_LOG_STREAM_CALL_STATIC(level, args) \ 
    271  
    272 #define RRLIB_LOG_PRINT_STATIC(level, args...) \ 
    273   RRLIB_LOG_PRINT_CALL_STATIC(level, args) \ 
    274  
    275 /*! Macro for messages using printf syntax 
    276  * 
    277  * \param level    The level of the message 
    278  * \param domain   The domain the message should be processed in 
    279  * \param args     The format string for printf and the optional arguments to be printed. 
    280  */ 
    281 #define RRLIB_LOG_MESSAGE(level, args...) \ 
    282   RRLIB_LOG_PRINTF_CALL(level, args) \ 
    283  
    284 #define RRLIB_LOG_PRINTF(level, args...) \ 
    285   RRLIB_LOG_PRINTF_CALL(level, args) \ 
    286  
    287 /*! Macro for messages using printf syntax from static context 
    288  * 
    289  * \param level    The level of the message 
    290  * \param domain   The domain the message should be processed in 
    291  * \param args     The format string for printf and the optional arguments to be printed. 
    292  */ 
    293 #define RRLIB_LOG_MESSAGE_STATIC(level, args...) \ 
    294   RRLIB_LOG_PRINTF_CALL_STATIC(level, args) \ 
    295  
    296 #define RRLIB_LOG_PRINTF_STATIC(level, args...) \ 
    297   RRLIB_LOG_PRINTF_CALL_STATIC(level, args) \ 
    298279 
    299280#endif 
    300  
    301 /*! Macro for creation of a default domain for the current scope 
    302  * 
    303  *  Typical use of logging domains is the creation of a domain for 
    304  *  a specific scope. That means, that the domain is valid between 
    305  *  the enclosing curly brackets. It exists in the domain hierarchy 
    306  *  below the last defined domain of a higher scope. 
    307  *  Using the same name in different scopes at the same level 
    308  *  results in reopening the same domain and combining the log 
    309  *  messages. 
    310  * 
    311  * \param domain_name   The local part of the name in the domain tree. 
    312  */ 
    313 #define RRLIB_LOG_CREATE_DEFAULT_DOMAIN(domain_name) \ 
    314   struct default_log_struct \ 
    315   { \ 
    316     static rrlib::logging::tLogDomainSharedPointer GetDomain() \ 
    317     { \ 
    318       static rrlib::logging::tLogDomainSharedPointer instance(rrlib::logging::tLogDomainRegistry::GetInstance()->GetSubDomain(domain_name, RRLIB_DEFAULT_LOG_DOMAIN_NAME())); \ 
    319       return instance; \ 
    320     } \ 
    321   }; \ 
    322   inline static rrlib::logging::tLogDomainSharedPointer default_log() \ 
    323   { \ 
    324     return default_log_struct::GetDomain(); \ 
    325   } \ 
    326  
    327 /*! Macro for creation of a new named domain for the current scope 
    328  * 
    329  *  A named logging domain can exist in parallel to the default 
    330  *  domain in the same scope. It then has a symbolic name that can 
    331  *  be specified in RRLIB_LOG_STREAM or RRLIB_LOG_MESSAGE. Thus, it 
    332  *  is possible to define more specific domains for one scope for 
    333  *  purposes like writing data to a file or being more selective in 
    334  *  message processing. 
    335  * 
    336  *  In the domain hierarchy the named logging domain exists below the 
    337  *  last created default domain. That means that first creating a 
    338  *  named domain and then creating the scoped domain places both at 
    339  *  the same level whereas changing the order places the named domain 
    340  *  below the current default_log. 
    341  * 
    342  * \param symbolic_name   The name that can be used in following code to use the new domain 
    343  * \param domain_name     The local part of the name in the domain tree. 
    344  */ 
    345 #define RRLIB_LOG_CREATE_NAMED_DOMAIN(symbolic_name, domain_name) \ 
    346   struct symbolic_name ## _struct \ 
    347   { \ 
    348     static rrlib::logging::tLogDomainSharedPointer GetDomain() \ 
    349     { \ 
    350       static rrlib::logging::tLogDomainSharedPointer instance(rrlib::logging::tLogDomainRegistry::GetInstance()->GetSubDomain(domain_name, RRLIB_DEFAULT_LOG_DOMAIN_NAME())); \ 
    351       return instance; \ 
    352     } \ 
    353   }; \ 
    354   inline static rrlib::logging::tLogDomainSharedPointer symbolic_name() \ 
    355   { \ 
    356     return symbolic_name ## _struct::GetDomain(); \ 
    357   } \ 
    358  
    359  
    360 #endif 
  • messages/implementation.h

    r64 r68  
    2020// 
    2121//---------------------------------------------------------------------- 
    22 /*!\file    definitions.h 
     22/*!\file    messages/implementation.h 
    2323 * 
    2424 * \author  Tobias Foehst 
    25  * \author  Max Reichardt 
    2625 * 
    27  * \date    2010-06-16 
     26 * \date    2011-09-15 
    2827 * 
    29  * \brief Contains macro definitions for using the RRLib logging framework 
     28 * \brief Contains the implementation of message printing 
    3029 * 
    31  * \b Creating Domains 
    32  * 
    33  * A few words for definitions.h 
    34  * 
    35  * \b Log Messages 
    36  * 
    37  * A few words for definitions.h 
     30 * A few words for implementation.h 
    3831 * 
    3932 */ 
    4033//---------------------------------------------------------------------- 
    41 #ifndef __rrlib__logging__definitions_h__ 
    42 #define __rrlib__logging__definitions_h__ 
     34#ifndef __rrlib__logging__include_guard__ 
     35#error Invalid include directive. Try #include "rrlib/logging/messages.h" instead. 
     36#endif 
     37 
     38#ifndef __rrlib__logging__messages__implementation_h__ 
     39#define __rrlib__logging__messages__implementation_h__ 
    4340 
    4441//---------------------------------------------------------------------- 
    4542// External includes (system with <>, local with "") 
    4643//---------------------------------------------------------------------- 
     44#include <iostream> 
     45#include <cstdarg> 
    4746 
    4847//---------------------------------------------------------------------- 
    4948// Internal includes with "" 
    5049//---------------------------------------------------------------------- 
    51 #define __rrlib__logging__include_guard__ 
    52  
    53 #include "rrlib/logging/tLogDomain.h" 
    54 #include "rrlib/logging/tLogDomainRegistry.h" 
    55  
    56 #undef __rrlib__logging__include_guard__ 
     50#include "rrlib/logging/log_levels.h" 
     51#include "rrlib/logging/configuration/tLogDomainRegistry.h" 
     52#include "rrlib/logging/configuration/tConfiguration.h" 
    5753 
    5854//---------------------------------------------------------------------- 
     
    6763// Implementation 
    6864//---------------------------------------------------------------------- 
    69 //! The default description for global debugging. Can be set to whatever string the user like to set it to 
     65//! The default description for global debugging. Can be set to whatever string the user likes to set it to 
    7066extern char *default_log_description; 
    7167 
    72 template <typename ... Types> 
    73 inline rrlib::logging::tLogDomainSharedPointer GetLogDomain(rrlib::logging::tLogDomainSharedPointer(&default_domain)(), const Types &...) 
     68const tConfiguration &GetConfiguration(const char *filename, const char *domain_name = 0); 
     69 
     70template <typename TLogDescription, typename ... TArgs> 
     71void Print(const tConfiguration &domain_configuration, const TLogDescription &log_description, const char *function, const char *filename, unsigned int line, tLogLevel level, const TArgs &... args) 
    7472{ 
    75   return default_domain(); 
     73  if (level > domain_configuration.MaxMessageLevel()) 
     74  { 
     75    return; 
     76  } 
     77 
     78  std::cout << domain_configuration.GetFullQualifiedName() << " " << log_description << std::endl; 
     79 
    7680} 
    77 inline rrlib::logging::tLogDomainSharedPointer GetLogDomain(rrlib::logging::tLogDomainSharedPointer(&default_domain)(), rrlib::logging::tLogDomainSharedPointer(&named_domain)()) 
     81 
     82template <typename TLogDescription> 
     83void PrintFormatted(const tConfiguration &domain_configuration, const TLogDescription &log_description, const char *function, const char *filename, unsigned int line, tLogLevel level, const char *fmt, ...) 
    7884{ 
    79   return named_domain(); 
     85  if (level > domain_configuration.MaxMessageLevel()) 
     86  { 
     87    return; 
     88  } 
     89 
     90  va_list printf_args0; 
     91  va_start(printf_args0, fmt); 
     92  char temp; 
     93  int needed_buffer_size = vsnprintf(&temp, 1, fmt, printf_args0); 
     94  va_end(printf_args0); 
     95 
     96  va_list printf_args1; 
     97  va_start(printf_args1, fmt); 
     98  char buffer[needed_buffer_size + 1]; 
     99  vsnprintf(buffer, sizeof(buffer), fmt, printf_args1); 
     100  va_end(printf_args1); 
     101 
     102  Print(domain_configuration, log_description, function, filename, line, level, static_cast<const char *>(buffer)); 
    80103} 
    81104 
     
    86109} 
    87110 
    88 //---------------------------------------------------------------------- 
    89 // Implementation of the global logging domain 
    90 //---------------------------------------------------------------------- 
    91 // The default global scoped logging domain 
    92 inline rrlib::logging::tLogDomainSharedPointer default_log() 
    93 { 
    94   return rrlib::logging::tLogDomainRegistry::GetDefaultDomain(); 
    95 } 
    96  
    97 // The default global GetLogDescription definition 
    98 inline const char *GetLogDescription() 
    99 { 
    100   return rrlib::logging::default_log_description; 
    101 } 
    102  
    103 //---------------------------------------------------------------------- 
    104 // Macros for internal use 
    105 //---------------------------------------------------------------------- 
    106 #define RRLIB_DEFAULT_LOG_DOMAIN_NAME default_log 
    107  
    108 #define RRLIB_LOG_GET_DOMAIN_I(domain...) \ 
    109   rrlib::logging::GetLogDomain(RRLIB_DEFAULT_LOG_DOMAIN_NAME, ## domain) \ 
    110  
    111 #define RRLIB_LOG_GET_DOMAIN(domain, args...) \ 
    112   RRLIB_LOG_GET_DOMAIN_I(domain) 
    113  
    114 #define RRLIB_LOG_STREAM_CALL(level, args...) \ 
    115   ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel() ? RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args) : RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level)) \ 
    116  
    117 #define RRLIB_LOG_STREAM_CALL_STATIC(level, args...) \ 
    118   ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel() ? RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream("<static>", __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args) : RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream("<static>", __FUNCTION__, __FILE__, __LINE__, level)) \ 
    119  
    120 #define RRLIB_LOG_PRINT_CALL(level, args...) \ 
    121   do \ 
    122   { \ 
    123     if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
    124     { \ 
    125       RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args); \ 
    126     } \ 
    127   } while (0) \ 
    128  
    129 #define RRLIB_LOG_PRINT_CALL_STATIC(level, args...) \ 
    130   do \ 
    131   { \ 
    132     if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
    133     { \ 
    134       RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream("<static>", __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args); \ 
    135     } \ 
    136   } while (0) \ 
    137  
    138 #define RRLIB_LOG_PRINTF_CALL(level, args...) \ 
    139   do \ 
    140   { \ 
    141     if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
    142     { \ 
    143       RRLIB_LOG_GET_DOMAIN(args)->PrintMessage(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level, args); \ 
    144     } \ 
    145   } while (0) \ 
    146  
    147 #define RRLIB_LOG_PRINTF_CALL_STATIC(level, args...) \ 
    148   do \ 
    149   { \ 
    150     if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
    151     { \ 
    152       RRLIB_LOG_GET_DOMAIN(args)->PrintMessage("<static>", __FUNCTION__, __FILE__, __LINE__, level, args); \ 
    153     } \ 
    154   } while (0) \ 
    155  
    156 //---------------------------------------------------------------------- 
    157 // The macro interface to the logging library 
    158 //---------------------------------------------------------------------- 
    159 #ifdef _RRLIB_LOGGING_LESS_OUTPUT_ 
    160  
    161 /*! Macro to get a stream for messages using operator << 
    162  * 
    163  * \param level    The level of the message 
    164  * \param domain   The domain the message should be processed in 
    165  * 
    166  * \returns The stream for message output 
    167  */ 
    168 #define RRLIB_LOG_STREAM(level, args...) \ 
    169   RRLIB_LOG_STREAM_CALL(level, args) \ 
    170  
    171 #define RRLIB_LOG_PRINT(level, args...) \ 
    172     do \ 
    173     { \ 
    174       if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    175       { \ 
    176         RRLIB_LOG_PRINT_CALL(level, args); \ 
    177       } \ 
    178     } while (0) \ 
    179  
    180 /*! Macro to get a stream for messages using operator << from static context 
    181  * 
    182  * \param level    The level of the message 
    183  * \param domain   The domain the message should be processed in 
    184  * 
    185  * \returns The stream for message output 
    186  */ 
    187 #define RRLIB_LOG_STREAM_STATIC(level, args...) \ 
    188   RRLIB_LOG_STREAM_CALL_STATIC(level, args) \ 
    189  
    190 #define RRLIB_LOG_PRINT_STATIC(level, args...) \ 
    191     do \ 
    192     { \ 
    193       if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    194       { \ 
    195         RRLIB_LOG_PRINT_CALL_STATIC(level, args); \ 
    196       } \ 
    197     } while (0) \ 
    198  
    199 /*! Macro for messages using printf syntax 
    200  * 
    201  * \param level    The level of the message 
    202  * \param domain   The domain the message should be processed in 
    203  * \param args     The format string for printf and the optional arguments to be printed. 
    204  */ 
    205 #define RRLIB_LOG_MESSAGE(level, args...) \ 
    206   do \ 
    207   { \ 
    208     if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    209     { \ 
    210       RRLIB_LOG_PRINTF_CALL(level, args); \ 
    211     } \ 
    212   } while (0) \ 
    213  
    214 #define RRLIB_LOG_PRINTF(level, args...) \ 
    215   do \ 
    216   { \ 
    217     if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    218     { \ 
    219       RRLIB_LOG_PRINTF_CALL(level, args); \ 
    220     } \ 
    221   } while (0) \ 
    222  
    223 /*! Macro for messages using printf syntax from static context 
    224  * 
    225  * \param level    The level of the message 
    226  * \param domain   The domain the message should be processed in 
    227  * \param args     The format string for printf and the optional arguments to be printed. 
    228  */ 
    229 #define RRLIB_LOG_MESSAGE_STATIC(level, args...) \ 
    230   do \ 
    231   { \ 
    232     if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    233     { \ 
    234       RRLIB_LOG_PRINTF_CALL_STATIC(level, args); \ 
    235     } \ 
    236   } while (0) \ 
    237  
    238 #define RRLIB_LOG_PRINTF_STATIC(level, args...) \ 
    239   do \ 
    240   { \ 
    241     if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    242     { \ 
    243       RRLIB_LOG_PRINTF_CALL_STATIC(level, args); \ 
    244     } \ 
    245   } while (0) \ 
    246  
    247 #else 
    248  
    249 /*! Macro to get a stream for messages using operator << 
    250  * 
    251  * \param level    The level of the message 
    252  * \param domain   The domain the message should be processed in 
    253  * 
    254  * \returns The stream for message output 
    255  */ 
    256 #define RRLIB_LOG_STREAM(level, args...) \ 
    257   RRLIB_LOG_STREAM_CALL(level, args) \ 
    258  
    259 #define RRLIB_LOG_PRINT(level, args...) \ 
    260   RRLIB_LOG_PRINT_CALL(level, args) \ 
    261  
    262 /*! Macro to get a stream for messages using operator << from static context 
    263  * 
    264  * \param level    The level of the message 
    265  * \param domain   The domain the message should be processed in 
    266  * 
    267  * \returns The stream for message output 
    268  */ 
    269 #define RRLIB_LOG_STREAM_STATIC(level, args...) \ 
    270   RRLIB_LOG_STREAM_CALL_STATIC(level, args) \ 
    271  
    272 #define RRLIB_LOG_PRINT_STATIC(level, args...) \ 
    273   RRLIB_LOG_PRINT_CALL_STATIC(level, args) \ 
    274  
    275 /*! Macro for messages using printf syntax 
    276  * 
    277  * \param level    The level of the message 
    278  * \param domain   The domain the message should be processed in 
    279  * \param args     The format string for printf and the optional arguments to be printed. 
    280  */ 
    281 #define RRLIB_LOG_MESSAGE(level, args...) \ 
    282   RRLIB_LOG_PRINTF_CALL(level, args) \ 
    283  
    284 #define RRLIB_LOG_PRINTF(level, args...) \ 
    285   RRLIB_LOG_PRINTF_CALL(level, args) \ 
    286  
    287 /*! Macro for messages using printf syntax from static context 
    288  * 
    289  * \param level    The level of the message 
    290  * \param domain   The domain the message should be processed in 
    291  * \param args     The format string for printf and the optional arguments to be printed. 
    292  */ 
    293 #define RRLIB_LOG_MESSAGE_STATIC(level, args...) \ 
    294   RRLIB_LOG_PRINTF_CALL_STATIC(level, args) \ 
    295  
    296 #define RRLIB_LOG_PRINTF_STATIC(level, args...) \ 
    297   RRLIB_LOG_PRINTF_CALL_STATIC(level, args) \ 
    298  
    299 #endif 
    300  
    301 /*! Macro for creation of a default domain for the current scope 
    302  * 
    303  *  Typical use of logging domains is the creation of a domain for 
    304  *  a specific scope. That means, that the domain is valid between 
    305  *  the enclosing curly brackets. It exists in the domain hierarchy 
    306  *  below the last defined domain of a higher scope. 
    307  *  Using the same name in different scopes at the same level 
    308  *  results in reopening the same domain and combining the log 
    309  *  messages. 
    310  * 
    311  * \param domain_name   The local part of the name in the domain tree. 
    312  */ 
    313 #define RRLIB_LOG_CREATE_DEFAULT_DOMAIN(domain_name) \ 
    314   struct default_log_struct \ 
    315   { \ 
    316     static rrlib::logging::tLogDomainSharedPointer GetDomain() \ 
    317     { \ 
    318       static rrlib::logging::tLogDomainSharedPointer instance(rrlib::logging::tLogDomainRegistry::GetInstance()->GetSubDomain(domain_name, RRLIB_DEFAULT_LOG_DOMAIN_NAME())); \ 
    319       return instance; \ 
    320     } \ 
    321   }; \ 
    322   inline static rrlib::logging::tLogDomainSharedPointer default_log() \ 
    323   { \ 
    324     return default_log_struct::GetDomain(); \ 
    325   } \ 
    326  
    327 /*! Macro for creation of a new named domain for the current scope 
    328  * 
    329  *  A named logging domain can exist in parallel to the default 
    330  *  domain in the same scope. It then has a symbolic name that can 
    331  *  be specified in RRLIB_LOG_STREAM or RRLIB_LOG_MESSAGE. Thus, it 
    332  *  is possible to define more specific domains for one scope for 
    333  *  purposes like writing data to a file or being more selective in 
    334  *  message processing. 
    335  * 
    336  *  In the domain hierarchy the named logging domain exists below the 
    337  *  last created default domain. That means that first creating a 
    338  *  named domain and then creating the scoped domain places both at 
    339  *  the same level whereas changing the order places the named domain 
    340  *  below the current default_log. 
    341  * 
    342  * \param symbolic_name   The name that can be used in following code to use the new domain 
    343  * \param domain_name     The local part of the name in the domain tree. 
    344  */ 
    345 #define RRLIB_LOG_CREATE_NAMED_DOMAIN(symbolic_name, domain_name) \ 
    346   struct symbolic_name ## _struct \ 
    347   { \ 
    348     static rrlib::logging::tLogDomainSharedPointer GetDomain() \ 
    349     { \ 
    350       static rrlib::logging::tLogDomainSharedPointer instance(rrlib::logging::tLogDomainRegistry::GetInstance()->GetSubDomain(domain_name, RRLIB_DEFAULT_LOG_DOMAIN_NAME())); \ 
    351       return instance; \ 
    352     } \ 
    353   }; \ 
    354   inline static rrlib::logging::tLogDomainSharedPointer symbolic_name() \ 
    355   { \ 
    356     return symbolic_name ## _struct::GetDomain(); \ 
    357   } \ 
    358111 
    359112 
  • tLogDomain.cpp

    r63 r68  
    145145  { 
    146146    std::cerr << "RRLib Logging >> Prefix for file names not set. Can not use eMS_FILE." << std::endl 
    147               << "                 Consider calling tMessageDomainRegistry::GetInstance()->SetOutputFileNamePrefix(basename(argv[0])) for example." << std::endl; 
     147              << "                 Consider calling tLogDomainRegistry::GetInstance()->SetOutputFileNamePrefix(basename(argv[0])) for example." << std::endl; 
    148148    return false; 
    149149  } 
  • tLogDomain.h

    r53 r68  
    3434 * can be created and configured via tLogDomainRegistry. That given, 
    3535 * in the program implementation instances of the class tLogDomain 
    36  * wrap the stream that can be access either in C++ iostream style via 
     36 * wrap the stream that can be accessed either in C++ iostream style via 
    3737 * operator << or in good old-fashioned C style using printf formatting. 
    3838 * 
  • test/libA/libA.h

    r62 r68  
    22#define _LIBA_H_ 
    33 
    4 #include "rrlib/logging/definitions.h" 
     4#include "rrlib/logging/messages.h" 
    55 
    66namespace libA 
    77{ 
    8 RRLIB_LOG_CREATE_DEFAULT_DOMAIN("libA"); 
    9  
    108void Test() 
    119{ 
  • test/libB/libB.h

    r62 r68  
    22#define _LIBB_H_ 
    33 
    4 #include "rrlib/logging/definitions.h" 
     4#include "rrlib/logging/messages.h" 
    55 
    66namespace libB 
    77{ 
    8 RRLIB_LOG_CREATE_DEFAULT_DOMAIN("libB"); 
    9  
    108void Test() 
    119{ 
  • test/test_messages.cpp

    r67 r68  
    5353// Debugging 
    5454//---------------------------------------------------------------------- 
    55 #include "rrlib/logging/test/debugging.h" 
    5655 
    5756//---------------------------------------------------------------------- 
     
    7574{ 
    7675 
    77 RRLIB_LOG_CREATE_DEFAULT_DOMAIN("local"); 
    78  
    7976struct Test 
    8077{ 
    81   RRLIB_LOG_CREATE_NAMED_DOMAIN(my_domain, "class"); 
    82  
    8378  static void function() 
    8479  { 
    85     RRLIB_LOG_PRINT(eLL_DEBUG_WARNING, my_domain, "this ", "is a ", "local class test"); 
     80    RRLIB_LOG_PRINT_EXPLICIT(eLL_DEBUG_WARNING, "my_domain", "this ", "is a ", "local class test"); 
    8681 
    8782    RRLIB_LOG_PRINT(eLL_WARNING, "foo"); 
    88     RRLIB_LOG_PRINT(eLL_ERROR, my_domain, "foo2"); 
     83    RRLIB_LOG_PRINT_EXPLICIT(eLL_ERROR, "my_domain", "foo2"); 
    8984    if (true) 
    9085    { 
    91       RRLIB_LOG_PRINTF(eLL_DEBUG, my_domain, "%s\n", "FOO"); 
     86      RRLIB_LOG_PRINTF_EXPLICIT(eLL_DEBUG, "my_domain", "%s\n", "FOO"); 
    9287    } 
    9388  } 
     
    127122#endif 
    128123 
    129   tLogDomainRegistry::GetInstance()->SetOutputFileNamePrefix(basename(argv[0])); 
     124//  tLogDomainRegistry::GetInstance()->SetOutputFileNamePrefix(basename(argv[0])); 
    130125 
    131126 
     
    154149  local::Test::function(); 
    155150 
    156   DEBUGMSG("blablabla Debug"); 
    157   INFOMSG("blablabla Info"); 
    158   WARNINGMSG("blablabla Warning"); 
    159   ERRORMSG("blablabla Error"); 
    160   USERMSG("blablabla User"); 
    161  
    162   RRLIB_LOG_PRINT(eLL_ERROR, std::runtime_error("runtime_error")); 
     151//  RRLIB_LOG_PRINT(eLL_ERROR, std::runtime_error("runtime_error")); 
    163152 
    164153  RRLIB_LOG_PRINT(eLL_WARNING, std::hex, 324); 
     
    168157 
    169158  const char* texts[] = {"Dies", "ist", "ein", "kleiner", "Text."}; 
    170   //std::copy(&texts[0], &texts[0] + 5, std::ostream_iterator<const char*>(RRLIB_LOG_PRINT(eLL_DEBUG), " "));   that is not pretty. use the following line.... 
    171159  RRLIB_LOG_PRINT(eLL_DEBUG, rrlib::util::Join(texts, texts + 5, " ")); 
    172160 
Note: See TracChangeset for help on using the changeset viewer.