[Libreoffice-commits] core.git: extensions/source officecfg/registry

Ariel Constenla-Haile arielch at apache.org
Tue May 28 01:14:36 PDT 2013


 extensions/source/logging/loggerconfig.cxx                  |   43 +++++++++++-
 officecfg/registry/schema/org/openoffice/Office/Logging.xcs |   18 ++++-
 2 files changed, 57 insertions(+), 4 deletions(-)

New commits:
commit 7e7e4c7a38764283ea334187fae4e21bd7d4f478
Author: Ariel Constenla-Haile <arielch at apache.org>
Date:   Mon Oct 15 03:36:40 2012 +0000

    Resolves: #i121216# Allow unique logger file name
    
    (cherry picked from commit a9606aa4d8a6bcb3955d991ee45c56cb93be2450)
    
    Conflicts:
    	officecfg/registry/schema/org/openoffice/Office/Logging.xcs
    
    Change-Id: I25719f2898df2f91ef9c71234e9eab83f8140b96

diff --git a/extensions/source/logging/loggerconfig.cxx b/extensions/source/logging/loggerconfig.cxx
index af0fac9..dae01ef 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 )
diff --git a/officecfg/registry/schema/org/openoffice/Office/Logging.xcs b/officecfg/registry/schema/org/openoffice/Office/Logging.xcs
index 2679d1f..5801359 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Logging.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Logging.xcs
@@ -46,9 +46,21 @@
         </info>
         <prop oor:name="FileURL" oor:type="xs:string" oor:nillable="false">
           <info>
-            <desc>Specifies the file URL for the log handler. The default value here will expand to a file
-            with the same name as the logger for which the handler is used, with extension ".log".
-            It will be located in the user's OOo data folder.</desc>
+            <desc>Specifies the file URL for the log handler.
+                This URL will be resolved using the
+                ::com::sun::star::util::PathSubstitution service. That is, it is
+                allowed to include placeholders supported by that service,
+                such as $(userurl). Beside these, the following default
+                placeholders can also be included:
+                    $(loggername) - the name of the logger
+                    $(date) - the current date
+                    $(time) - the current time
+                    $(datetime) - the current date time
+                    $(pid) - the process identifier
+                The default value here will expand to a file with the same name
+                as the logger for which the handler is used, with extension ".log".
+                It will be located in the user's OOo data folder.
+            </desc>
           </info>
           <value>$(userurl)/$(loggername).log</value>
         </prop>


More information about the Libreoffice-commits mailing list