wiki:Documentation/Logging

Logging support

Ariba uses an internal logging system that you are free to use. Depending on the platform, logging goes through log4cxx or directly to std::cout. The Ariba configure script will check for availability of log4cxx on your system and use it if available.

All important definitions can be found in "ariba/utility/logging/Logging.h" To use logging in your application on a per-class basis, perform the following steps:

  • If you want to use colors for the different logging-levels you can use the option --enable-logcolors=yes
  • Include the logging header #include "ariba/utility/logging/Logging.h" in the header of your class where you want to use logging.
  • Right inside the class definition of your .h class TestClass to use the following: use_logging_h(TestClass). In the .cpp source file use use_logging_cpp(TestClass).
  • The order of log-level is "debug", "info", "warning", "error". The default log-level is "info".
  • To change the default log-level you can use the functions
    • logging_rootlevel_debug();
    • logging_rootlevel_info();
    • logging_rootlevel_warn();
    • logging_rootlevel_error();
  • To change the individual log-level of a class you can e.g. first set the global level to "warn" and then for your test-class to "debug". This feature is only available when you have log4cxx installed
         logging_rootlevel_warn();
         logging_classlevel_debug("TestClass");
    
  • The log-level functions for individual classes are
    • logging_classlevel_debug("TestClass")
    • logging_classlevel_info("TestClass")
    • logging_classlevel_warn("TestClass")
    • logging_classlevel_error("TestClass")
  • Finally, the functions to actually perform logging at the different levels are ("fatal" will kill the program)
    • logging_debug("this is a log message")
    • logging_info("this is a log message")
    • logging_warn("this is a log message")
    • logging_error("this is a log message")
    • logging_fatal("this is a log message")
Last modified 14 years ago Last modified on Apr 7, 2011, 4:34:31 PM
Note: See TracWiki for help on using the wiki.