diff options
author | Dirk Grobler <dg@openoffice.org> | 2001-02-13 08:48:02 +0000 |
---|---|---|
committer | Dirk Grobler <dg@openoffice.org> | 2001-02-13 08:48:02 +0000 |
commit | 249b98a27ea660cdda09c704ffc0b00944903f32 (patch) | |
tree | a35a433d5657517b01548ae9e3a7846f71355951 /configmgr | |
parent | 1b4f40404d52242a2964c835c256ae63c0788284 (diff) |
#83239# timing output
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/inc/tracer.hxx | 14 | ||||
-rw-r--r-- | configmgr/source/misc/tracer.cxx | 56 |
2 files changed, 62 insertions, 8 deletions
diff --git a/configmgr/source/inc/tracer.hxx b/configmgr/source/inc/tracer.hxx index 27eba4317f86..c0e97cd31505 100644 --- a/configmgr/source/inc/tracer.hxx +++ b/configmgr/source/inc/tracer.hxx @@ -2,9 +2,9 @@ * * $RCSfile: tracer.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:13:41 $ + * last change: $Author: dg $ $Date: 2001-02-13 09:47:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -78,6 +78,7 @@ #include <stdarg.h> #include <stdio.h> +#include <sys/timeb.h> #define OUSTRING2ASCII(rtlOUString) ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), RTL_TEXTENCODING_ASCII_US).getStr() @@ -88,6 +89,7 @@ #define CFG_TRACE_WARNING_NI OConfigTracer::traceWarning #define CFG_TRACE_ERROR_NI OConfigTracer::traceError + #define CFG_TRACE_TO_DEVICE OConfigTracer::traceToVirtualDevice namespace configmgr @@ -101,6 +103,7 @@ class OConfigTracer protected: static ::osl::Mutex s_aMutex; static OTracerSetup* s_pImpl; + static timeb s_aStartTime; private: OConfigTracer(); // never implemented, no instantiation of this class allowed, only static members @@ -109,13 +112,15 @@ public: static void traceInfo(const sal_Char* _pFormat, ...); static void traceWarning(const sal_Char* _pFormat, ...); static void traceError(const sal_Char* _pFormat, ...); - static void traceToVirtualDevice(const sal_Char* _pDeviceName, const sal_Char* _pFormat, ...); static ::rtl::OString getTimeStamp(); protected: + static void trace(const sal_Char* _pFormat, ...); static void implTrace(const sal_Char* _pType, const sal_Char* _pFormat, va_list args); + static void startGlobalTimer(); + static sal_uInt32 getGlobalTimer(); static void inc(); static void dec(); @@ -156,6 +161,9 @@ public: //************************************************************************** // history: // $Log: not supported by cvs2svn $ +// Revision 1.1.1.1 2000/09/18 16:13:41 hr +// initial import +// // Revision 1.6 2000/09/15 09:51:50 willem.vandorp // OpenOffice header added // diff --git a/configmgr/source/misc/tracer.cxx b/configmgr/source/misc/tracer.cxx index db294f636ebc..1e59f6b9e470 100644 --- a/configmgr/source/misc/tracer.cxx +++ b/configmgr/source/misc/tracer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: tracer.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: fs $ $Date: 2000-11-29 12:45:31 $ + * last change: $Author: dg $ $Date: 2001-02-13 09:48:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,6 +88,7 @@ namespace configmgr #define INFO 1 #define WARNING 2 #define ERROR 4 +#define TIME 8 namespace configmgr { @@ -115,6 +116,24 @@ struct OTracerSetup //========================================================================== ::osl::Mutex OConfigTracer::s_aMutex; OTracerSetup* OConfigTracer::s_pImpl = NULL; +timeb OConfigTracer::s_aStartTime; + + +//-------------------------------------------------------------------------- +void OConfigTracer::startGlobalTimer() +{ + ftime( &s_aStartTime ); +} + +//-------------------------------------------------------------------------- +sal_uInt32 OConfigTracer::getGlobalTimer() +{ + struct timeb currentTime; + sal_uInt32 nSeconds; + ftime( ¤tTime ); + nSeconds = (sal_uInt32)( currentTime.time - s_aStartTime.time ); + return ( nSeconds * 1000 ) + (long)( currentTime.millitm - s_aStartTime.millitm ); +} //-------------------------------------------------------------------------- void OConfigTracer::ensureData() @@ -147,9 +166,18 @@ void OConfigTracer::traceInfo(const sal_Char* _pFormat, ...) ensureData(); if (s_pImpl->s_nTraceMask & INFO) { + + va_list args; va_start(args, _pFormat); - implTrace("info : ", _pFormat, args); + if (s_pImpl->s_nTraceMask & TIME) + { + static sal_Char szMessage[1024] = ""; + sprintf(szMessage, "info (%06lu): ", getGlobalTimer()); + implTrace(szMessage, _pFormat, args); + } + else + implTrace("info : ", _pFormat, args); va_end(args); } } @@ -183,6 +211,15 @@ void OConfigTracer::traceError(const sal_Char* _pFormat, ...) } //-------------------------------------------------------------------------- +void OConfigTracer::trace(const sal_Char* _pFormat, ...) +{ + va_list args; + va_start(args, _pFormat); + implTrace("", _pFormat, args); + va_end(args); +} + +//-------------------------------------------------------------------------- void OConfigTracer::indent() { for (sal_Int32 i=0; i<s_pImpl->s_nIndentDepth; ++i) @@ -303,6 +340,9 @@ void OConfigTracer::ensureInitalized() case 'i': s_pImpl->s_nTraceMask |= INFO; break; case 'w': s_pImpl->s_nTraceMask |= WARNING; break; case 'e': s_pImpl->s_nTraceMask |= ERROR; break; + case 'p': s_pImpl->s_nTraceMask |= TIME; + startGlobalTimer(); + break; } ++pSettings; } @@ -366,8 +406,11 @@ void OConfigTracer::implTrace(const sal_Char* _pType, const sal_Char* _pFormat, // no tracing enabled return; - fprintf(s_pImpl->s_pOutputMedium, "%s", _pType); - indent(); + if (_pType && strlen(_pType)) + { + fprintf(s_pImpl->s_pOutputMedium, "%s", _pType); + indent(); + } vfprintf(s_pImpl->s_pOutputMedium, _pFormat, args); fprintf(s_pImpl->s_pOutputMedium,"\n"); fflush(s_pImpl->s_pOutputMedium); @@ -380,6 +423,9 @@ void OConfigTracer::implTrace(const sal_Char* _pType, const sal_Char* _pFormat, //************************************************************************** // history: // $Log: not supported by cvs2svn $ +// Revision 1.3 2000/11/29 12:45:31 fs +// #80122# additional traces upon initialization (process id / executable name) +// // Revision 1.2 2000/11/07 12:14:37 hr // #65293#: includes // |