loggerconfig.cxx (2a97ec55) loggerconfig.cxx (197bf4dc)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 11 unchanged lines hidden (view full) ---

20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_extensions.hxx"
26
27#include "loggerconfig.hxx"
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 11 unchanged lines hidden (view full) ---

20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_extensions.hxx"
26
27#include "loggerconfig.hxx"
28#include <stdio.h>
28
29/** === begin UNO includes === **/
30#include <com/sun/star/lang/XMultiServiceFactory.hpp>
31#include <com/sun/star/container/XNameContainer.hpp>
32#include <com/sun/star/lang/XSingleServiceFactory.hpp>
33#include <com/sun/star/util/XChangesBatch.hpp>
34#include <com/sun/star/logging/LogLevel.hpp>
35#include <com/sun/star/lang/NullPointerException.hpp>
36#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
37#include <com/sun/star/beans/NamedValue.hpp>
38#include <com/sun/star/logging/XLogHandler.hpp>
39#include <com/sun/star/logging/XLogFormatter.hpp>
40/** === end UNO includes === **/
41
42#include <tools/diagnose_ex.h>
29
30/** === begin UNO includes === **/
31#include <com/sun/star/lang/XMultiServiceFactory.hpp>
32#include <com/sun/star/container/XNameContainer.hpp>
33#include <com/sun/star/lang/XSingleServiceFactory.hpp>
34#include <com/sun/star/util/XChangesBatch.hpp>
35#include <com/sun/star/logging/LogLevel.hpp>
36#include <com/sun/star/lang/NullPointerException.hpp>
37#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
38#include <com/sun/star/beans/NamedValue.hpp>
39#include <com/sun/star/logging/XLogHandler.hpp>
40#include <com/sun/star/logging/XLogFormatter.hpp>
41/** === end UNO includes === **/
42
43#include <tools/diagnose_ex.h>
44#include <osl/process.h>
45#include <rtl/ustrbuf.hxx>
43
44#include <comphelper/componentcontext.hxx>
45
46#include <cppuhelper/component_context.hxx>
47
48#include <vector>
49
50//........................................................................

--- 48 unchanged lines hidden (view full) ---

99 {
100 }
101 };
102
103 ::rtl::OUString sLoggerName;
104 try { sLoggerName = _rxLogger->getName(); }
105 catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
106
46
47#include <comphelper/componentcontext.hxx>
48
49#include <cppuhelper/component_context.hxx>
50
51#include <vector>
52
53//........................................................................

--- 48 unchanged lines hidden (view full) ---

102 {
103 }
104 };
105
106 ::rtl::OUString sLoggerName;
107 try { sLoggerName = _rxLogger->getName(); }
108 catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
109
110 TimeValue aTimeValue;
111 oslDateTime aDateTime;
112 OSL_VERIFY( osl_getSystemTime( &aTimeValue ) );
113 OSL_VERIFY( osl_getDateTimeFromTimeValue( &aTimeValue, &aDateTime ) );
114
115 char buffer[ 30 ];
116 const size_t buffer_size = sizeof( buffer );
117
118 snprintf( buffer, buffer_size, "%04i-%02i-%02i",
119 (int)aDateTime.Year,
120 (int)aDateTime.Month,
121 (int)aDateTime.Day );
122 rtl::OUString sDate = rtl::OUString::createFromAscii( buffer );
123
124 snprintf( buffer, buffer_size, "%02i-%02i-%02i.%03i",
125 (int)aDateTime.Hours,
126 (int)aDateTime.Minutes,
127 (int)aDateTime.Seconds,
128 ::sal::static_int_cast< sal_Int16 >( aDateTime.NanoSeconds / 10000000 ) );
129 rtl::OUString sTime = rtl::OUString::createFromAscii( buffer );
130
131 rtl::OUStringBuffer aBuff;
132 aBuff.append( sDate );
133 aBuff.append( sal_Unicode( '.' ) );
134 aBuff.append( sTime );
135 rtl::OUString sDateTime = aBuff.makeStringAndClear();
136
137 oslProcessIdentifier aProcessId = 0;
138 oslProcessInfo info;
139 info.Size = sizeof (oslProcessInfo);
140 if ( osl_getProcessInfo ( 0, osl_Process_IDENTIFIER, &info ) == osl_Process_E_None)
141 aProcessId = info.Ident;
142 rtl::OUString aPID = rtl::OUString::valueOf( sal_Int64( aProcessId ) );
143
107 Variable aVariables[] =
108 {
144 Variable aVariables[] =
145 {
109 Variable( RTL_CONSTASCII_USTRINGPARAM( "$(loggername)" ), sLoggerName )
146 Variable( RTL_CONSTASCII_USTRINGPARAM( "$(loggername)" ), sLoggerName ),
147 Variable( RTL_CONSTASCII_USTRINGPARAM( "$(date)" ), sDate ),
148 Variable( RTL_CONSTASCII_USTRINGPARAM( "$(time)" ), sTime ),
149 Variable( RTL_CONSTASCII_USTRINGPARAM( "$(datetime)" ), sDateTime ),
150 Variable( RTL_CONSTASCII_USTRINGPARAM( "$(pid)" ), aPID )
110 };
111
112 for ( size_t i = 0; i < sizeof( aVariables ) / sizeof( aVariables[0] ); ++i )
113 {
114 ::rtl::OUString sPattern( aVariables[i].pVariablePattern, aVariables[i].nPatternLength, aVariables[i].eEncoding );
115 sal_Int32 nVariableIndex = _inout_rFileURL.indexOf( sPattern );
116 if ( ( nVariableIndex == 0 )
117 || ( ( nVariableIndex > 0 )

--- 162 unchanged lines hidden ---
151 };
152
153 for ( size_t i = 0; i < sizeof( aVariables ) / sizeof( aVariables[0] ); ++i )
154 {
155 ::rtl::OUString sPattern( aVariables[i].pVariablePattern, aVariables[i].nPatternLength, aVariables[i].eEncoding );
156 sal_Int32 nVariableIndex = _inout_rFileURL.indexOf( sPattern );
157 if ( ( nVariableIndex == 0 )
158 || ( ( nVariableIndex > 0 )

--- 162 unchanged lines hidden ---