Changeset 77:bd3586b6ab9e in rrlib_logging


Ignore:
Timestamp:
14.01.2012 23:33:36 (9 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Parents:
70:fb977138a844 (diff), 76:706ca58dc667 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merged with implicit_log_domains

Files:
12 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • test/test_messages.cpp

    r70 r77  
    3636#include <stdexcept> 
    3737#include <iterator> 
     38#include <iomanip> 
    3839 
    3940extern "C" 
     
    4344 
    4445#include "rrlib/util/join.h" 
     46 
     47#include "rrlib/logging/configuration.h" 
     48#include "rrlib/logging/messages.h" 
    4549 
    4650//---------------------------------------------------------------------- 
     
    5357// Debugging 
    5458//---------------------------------------------------------------------- 
    55 #include "rrlib/logging/test/debugging.h" 
    5659 
    5760//---------------------------------------------------------------------- 
    5861// Namespace usage 
    5962//---------------------------------------------------------------------- 
    60 using namespace rrlib::logging; 
    6163 
    6264//---------------------------------------------------------------------- 
     
    7577{ 
    7678 
    77 RRLIB_LOG_CREATE_DEFAULT_DOMAIN("local"); 
    78  
    7979struct Test 
    8080{ 
    81   RRLIB_LOG_CREATE_NAMED_DOMAIN(my_domain, "class"); 
    82  
    8381  static void function() 
    8482  { 
    85     RRLIB_LOG_PRINT(eLL_DEBUG_WARNING, my_domain, "this ", "is a ", "local class test"); 
     83    RRLIB_LOG_PRINT_TO(my_domain, rrlib::logging::eLL_DEBUG_WARNING, "this ", "is a ", "local class test"); 
    8684 
    87     RRLIB_LOG_PRINT(eLL_WARNING, "foo"); 
    88     RRLIB_LOG_PRINT(eLL_ERROR, my_domain, "foo2"); 
     85    RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "foo"); 
     86    RRLIB_LOG_PRINT_TO(my_domain, rrlib::logging::eLL_ERROR, "foo2"); 
    8987    if (true) 
    9088    { 
    91       RRLIB_LOG_PRINTF(eLL_DEBUG, my_domain, "%s\n", "FOO"); 
     89      RRLIB_LOG_PRINTF_TO(my_domain, rrlib::logging::eLL_DEBUG, "%s\n", "FOO"); 
    9290    } 
    9391  } 
     
    105103  static void StaticMethod() 
    106104  { 
    107     RRLIB_LOG_PRINT_STATIC(eLL_USER, "From static method"); 
     105    RRLIB_LOG_PRINT_STATIC(rrlib::logging::eLL_USER, "From static method"); 
    108106  } 
    109107 
    110108  void NonStaticMethod() 
    111109  { 
    112     RRLIB_LOG_PRINT(eLL_USER, "From non-static method"); 
     110    RRLIB_LOG_PRINT(rrlib::logging::eLL_USER, "From non-static method"); 
    113111  } 
    114112}; 
     
    117115int main(int argc, char **argv) 
    118116{ 
    119   default_log_description = basename(argv[0]); 
     117  rrlib::logging::default_log_description = basename(argv[0]); 
     118  rrlib::logging::SetLogFilenamePrefix(basename(argv[0])); 
    120119 
    121120#ifdef _LIB_RRLIB_XML2_WRAPPER_PRESENT_ 
    122   if (!tLogDomainRegistry::GetInstance()->ConfigureFromFile("logging_config.xml")) 
     121  if (!rrlib::logging::ConfigureFromFile("logging_config.xml")) 
    123122  { 
    124     std::cout << "Loading configuration failed!"; 
     123    RRLIB_LOG_PRINT(rrlib::logging::eLL_ERROR, "Loading configuration failed!"); 
    125124    return EXIT_FAILURE; 
    126125  } 
     126 
     127  rrlib::logging::PrintDomainConfigurations(); 
    127128#endif 
    128129 
    129   tLogDomainRegistry::GetInstance()->SetOutputFileNamePrefix(basename(argv[0])); 
     130//  rrlib::logging::SetDomainPrintsName(".", true); 
     131//  rrlib::logging::SetDomainPrintsTime(".", true); 
     132//  rrlib::logging::SetDomainPrintsLevel(".", true); 
     133//  rrlib::logging::SetDomainPrintsLocation(".", true); 
     134//  rrlib::logging::SetDomainMaxMessageLevel(".", rrlib::logging::eLL_DEBUG_VERBOSE_3); 
     135//  rrlib::logging::SetDomainSink(".", rrlib::logging::eLS_FILE); 
    130136 
     137  rrlib::logging::SetDomainMaxMessageLevel(".example", rrlib::logging::eLL_DEBUG_VERBOSE_3); 
     138//  rrlib::logging::SetDomainSink(".example", rrlib::logging::eLS_STDOUT, rrlib::logging::eLS_FILE_SUBTREE); 
    131139 
    132 //  std::cout << tLogDomainRegistry::GetInstance() << std::endl; 
    133  
    134 //  tLogDomainRegistry::GetInstance()->SetDomainConfiguresSubTree("global", true); 
    135 //  tLogDomainRegistry::GetInstance()->SetDomainPrintsName("global", true); 
    136 //  tLogDomainRegistry::GetInstance()->SetDomainPrintsTime("global", true); 
    137 //  tLogDomainRegistry::GetInstance()->SetDomainPrintsLevel("global", true); 
    138 //  tLogDomainRegistry::GetInstance()->SetDomainPrintsLocation("global", true); 
    139 //  tLogDomainRegistry::GetInstance()->SetDomainMinMessageLevel("global", eLL_VERBOSE); 
    140 //  tLogDomainRegistry::GetInstance()->SetDomainStreamID("global", eLS_FILE); 
    141  
    142 //  tLogDomainRegistry::GetInstance()->SetDomainStreamMask("global", eLSM_STDOUT | eLSM_FILE | eLSM_COMBINED_FILE); 
    143  
    144 //  tLogDomainRegistry::GetInstance()->SetDomainConfiguresSubTree(".example", true); 
    145 //  tLogDomainRegistry::GetInstance()->SetDomainMinMessageLevel(".example", eLL_VERBOSE); 
    146 //  tLogDomainRegistry::GetInstance()->SetDomainStreamID(".example", eLS_COMBINED_FILE); 
    147  
    148  
    149   RRLIB_LOG_PRINT(eLL_WARNING, "foo"); 
     140  RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "foo"); 
    150141 
    151142  libA::Test(); 
     
    154145  local::Test::function(); 
    155146 
    156   DEBUGMSG("blablabla Debug"); 
    157   INFOMSG("blablabla Info"); 
    158   WARNINGMSG("blablabla Warning"); 
    159   ERRORMSG("blablabla Error"); 
    160   USERMSG("blablabla User"); 
     147  RRLIB_LOG_PRINT(rrlib::logging::eLL_ERROR, std::runtime_error("runtime_error")); 
    161148 
    162   RRLIB_LOG_PRINT(eLL_ERROR, std::runtime_error("runtime_error")); 
     149  RRLIB_LOG_PRINT(rrlib::logging::eLL_WARNING, "0x", std::setw(20), std::setfill('0'), std::hex, 324); 
    163150 
    164   RRLIB_LOG_PRINT(eLL_WARNING, std::hex, 324); 
    165  
    166   RRLIB_LOG_PRINT(eLL_ERROR, "Das hier ist ein mehrzeiliger\nFehler."); 
    167   RRLIB_LOG_PRINT(eLL_USER, "Und das hier ein mehrzeiliger\nText fuer den lieben Benutzer."); 
     151  RRLIB_LOG_PRINT(rrlib::logging::eLL_ERROR, "Das hier ist ein mehrzeiliger\nFehler."); 
     152  RRLIB_LOG_PRINT(rrlib::logging::eLL_USER, "Und das hier ein mehrzeiliger\nText fuer den lieben Benutzer."); 
    168153 
    169154  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.... 
    171   RRLIB_LOG_PRINT(eLL_DEBUG, rrlib::util::Join(texts, texts + 5, " ")); 
     155  RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG, rrlib::util::Join(texts, texts + 5, " ")); 
    172156 
    173157  TestStatic test_static; 
     
    175159  test_static.NonStaticMethod(); 
    176160 
     161  int *a = 0; 
     162  const int *b = 0; 
     163  RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG, "Pointer: ", a); 
     164  RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG, "Const-Pointer: ", b); 
     165  RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG, "Bool: ", true, false); 
     166  RRLIB_LOG_PRINT(rrlib::logging::eLL_DEBUG, "Function: ", main); 
     167 
     168  rrlib::logging::PrintDomainConfigurations(); 
    177169  return EXIT_SUCCESS; 
    178170} 
Note: See TracChangeset for help on using the changeset viewer.