better formatting for operators

master
Marc Wäckerlin 20 years ago
parent c6c97559c1
commit 4f856c3281
  1. 39
      mrw/autofunctiontracelog4cxx.cpp

@ -9,6 +9,9 @@
@license LGPL, see file <a href="license.html">COPYING</a> @license LGPL, see file <a href="license.html">COPYING</a>
$Log$ $Log$
Revision 1.3 2005/04/14 19:12:18 marc
better formatting for operators
Revision 1.2 2005/04/07 20:42:38 marc Revision 1.2 2005/04/07 20:42:38 marc
renamed loggerhierarchy from mrw.gccfunctiontrace to mrw.fn renamed loggerhierarchy from mrw.gccfunctiontrace to mrw.fn
@ -108,27 +111,7 @@ extern "C" int main(int, char**);
necessary, because otherwise access the incompletely initialized necessary, because otherwise access the incompletely initialized
MRW-C++ library itself may cause a crash. MRW-C++ library itself may cause a crash.
I use the following log4cxx @c log4cxx::PropertyConfigurator A good default configuration is given in @ref AutoInitLog4cxx.
configuration in the test program to enable all function traces,
except from some third party and standard libraries:
@verbatim
log4j.rootLogger = OFF, A1
log4j.logger.mrw.fn = DEBUG, A1
log4j.logger.mrw.fn.log4cxx = OFF, A1
log4j.logger.mrw.fn.boost = OFF, A1
log4j.logger.mrw.fn.Thread = OFF, A1
log4j.logger.mrw.fn.mrw = OFF, A1
log4j.logger.mrw.fn.std = OFF, A1
log4j.logger.mrw.fn.new = OFF, A1
log4j.logger.mrw.fn.CppUnit = OFF, A1
log4j.logger.mrw.fn.__gnu_cxx = OFF, A1
log4j.appender.A1 = org.apache.log4j.FileAppender
log4j.appender.A1.layout = org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern = %t-%-41c%m%n
log4j.appender.A1.filename = filename.log
@endverbatim
Depending on your log4cxx configuration, a function trace may look Depending on your log4cxx configuration, a function trace may look
e.g. like this (very simple configuration with very few additional e.g. like this (very simple configuration with very few additional
information): information):
@ -155,8 +138,10 @@ mrw.fn.anotherFunction / anotherFunction()
@note The configurator is not installed automatically. If you @note The configurator is not installed automatically. If you
want to trace e.g. on the console, you have to call @c want to trace e.g. on the console, you have to call @c
log4cxx::BasicConfigurator::configure(); as first statement log4cxx::BasicConfigurator::configure(); as first statement
in your @c main(). @see @ref AutoInitLog4cxx if you also want to in your @c main().
automatically configure @c log4cxx.
@see @ref AutoInitLog4cxx if you also want to automatically
configure @c log4cxx.
@section AutoFunctionTraceThread Multithreading @section AutoFunctionTraceThread Multithreading
@ -190,7 +175,9 @@ extern "C" void __cyg_profile_func_enter(void *this_fn, void*) {
(p=hierarchy.find("::", p))!=std::string::npos; (p=hierarchy.find("::", p))!=std::string::npos;
hierarchy.replace(p, 2, ".")); hierarchy.replace(p, 2, "."));
hierarchy.erase(hierarchy.rfind('(')); hierarchy.erase(hierarchy.rfind('('));
std::string::size_type p(hierarchy.rfind(' ', hierarchy.find('<'))); std::string::size_type p
(hierarchy.rfind(' ', std::min(hierarchy.find('<'),
hierarchy.find("operator"))));
if (p!=std::string::npos) hierarchy.erase(0, p+1); if (p!=std::string::npos) hierarchy.erase(0, p+1);
log4cxx::Logger* logger log4cxx::Logger* logger
(log4cxx::Logger::getLogger(_T("mrw.fn.")+hierarchy)); (log4cxx::Logger::getLogger(_T("mrw.fn.")+hierarchy));
@ -223,7 +210,9 @@ extern "C" void __cyg_profile_func_exit(void *this_fn, void*) {
(p=hierarchy.find("::", p))!=std::string::npos; (p=hierarchy.find("::", p))!=std::string::npos;
hierarchy.replace(p, 2, ".")); hierarchy.replace(p, 2, "."));
hierarchy.erase(hierarchy.find('(')); hierarchy.erase(hierarchy.find('('));
std::string::size_type p(hierarchy.rfind(' ', hierarchy.find('<'))); std::string::size_type p
(hierarchy.rfind(' ', std::min(hierarchy.find('<'),
hierarchy.find("operator"))));
if (p!=std::string::npos) hierarchy.erase(0, p+1); if (p!=std::string::npos) hierarchy.erase(0, p+1);
log4cxx::Logger* logger log4cxx::Logger* logger
(log4cxx::Logger::getLogger(_T("mrw.fn.")+hierarchy)); (log4cxx::Logger::getLogger(_T("mrw.fn.")+hierarchy));

Loading…
Cancel
Save