summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2012-10-15 03:36:40 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-28 09:14:15 +0100
commit7e7e4c7a38764283ea334187fae4e21bd7d4f478 (patch)
treef1b33b52de5a859647cb524a99c6649817b4e59c /extensions
parent898a3e84807bccbb876e3f5583728f6d24e05e9a (diff)
Resolves: #i121216# Allow unique logger file name
(cherry picked from commit a9606aa4d8a6bcb3955d991ee45c56cb93be2450) Conflicts: officecfg/registry/schema/org/openoffice/Office/Logging.xcs Change-Id: I25719f2898df2f91ef9c71234e9eab83f8140b96
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/logging/loggerconfig.cxx43
1 files changed, 42 insertions, 1 deletions
diff --git a/extensions/source/logging/loggerconfig.cxx b/extensions/source/logging/loggerconfig.cxx
index af0fac9efa03..dae01ef2f96c 100644
--- a/extensions/source/logging/loggerconfig.cxx
+++ b/extensions/source/logging/loggerconfig.cxx
@@ -19,6 +19,7 @@
#include "loggerconfig.hxx"
+#include <stdio.h>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -33,6 +34,8 @@
#include <com/sun/star/logging/XLogFormatter.hpp>
#include <tools/diagnose_ex.h>
+#include <osl/process.h>
+#include <rtl/ustrbuf.hxx>
#include <comphelper/componentcontext.hxx>
@@ -97,9 +100,47 @@ namespace logging
try { sLoggerName = _rxLogger->getName(); }
catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ TimeValue aTimeValue;
+ oslDateTime aDateTime;
+ OSL_VERIFY( osl_getSystemTime( &aTimeValue ) );
+ OSL_VERIFY( osl_getDateTimeFromTimeValue( &aTimeValue, &aDateTime ) );
+
+ char buffer[ 30 ];
+ const size_t buffer_size = sizeof( buffer );
+
+ snprintf( buffer, buffer_size, "%04i-%02i-%02i",
+ (int)aDateTime.Year,
+ (int)aDateTime.Month,
+ (int)aDateTime.Day );
+ rtl::OUString sDate = rtl::OUString::createFromAscii( buffer );
+
+ snprintf( buffer, buffer_size, "%02i-%02i-%02i.%03i",
+ (int)aDateTime.Hours,
+ (int)aDateTime.Minutes,
+ (int)aDateTime.Seconds,
+ ::sal::static_int_cast< sal_Int16 >( aDateTime.NanoSeconds / 10000000 ) );
+ rtl::OUString sTime = rtl::OUString::createFromAscii( buffer );
+
+ rtl::OUStringBuffer aBuff;
+ aBuff.append( sDate );
+ aBuff.append( sal_Unicode( '.' ) );
+ aBuff.append( sTime );
+ rtl::OUString sDateTime = aBuff.makeStringAndClear();
+
+ oslProcessIdentifier aProcessId = 0;
+ oslProcessInfo info;
+ info.Size = sizeof (oslProcessInfo);
+ if ( osl_getProcessInfo ( 0, osl_Process_IDENTIFIER, &info ) == osl_Process_E_None)
+ aProcessId = info.Ident;
+ rtl::OUString aPID = rtl::OUString::valueOf( sal_Int64( aProcessId ) );
+
Variable aVariables[] =
{
- Variable( RTL_CONSTASCII_USTRINGPARAM( "$(loggername)" ), sLoggerName )
+ Variable( RTL_CONSTASCII_USTRINGPARAM( "$(loggername)" ), sLoggerName ),
+ Variable( RTL_CONSTASCII_USTRINGPARAM( "$(date)" ), sDate ),
+ Variable( RTL_CONSTASCII_USTRINGPARAM( "$(time)" ), sTime ),
+ Variable( RTL_CONSTASCII_USTRINGPARAM( "$(datetime)" ), sDateTime ),
+ Variable( RTL_CONSTASCII_USTRINGPARAM( "$(pid)" ), aPID )
};
for ( size_t i = 0; i < SAL_N_ELEMENTS( aVariables ); ++i )