xref: /AOO41X/main/extensions/source/logging/csvformatter.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3*cdf0e10cSrcweir  *
4*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
5*cdf0e10cSrcweir  *
6*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
7*cdf0e10cSrcweir  *
8*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
9*cdf0e10cSrcweir  *
10*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
11*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
12*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
13*cdf0e10cSrcweir  *
14*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
15*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
18*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
19*cdf0e10cSrcweir  *
20*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
21*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
22*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
23*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
24*cdf0e10cSrcweir  *
25*cdf0e10cSrcweir ************************************************************************/
26*cdf0e10cSrcweir 
27*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
28*cdf0e10cSrcweir #include "precompiled_extensions.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "log_module.hxx"
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <stdio.h>
33*cdf0e10cSrcweir #include <string>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir /** === begin UNO includes === **/
36*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LOGGING_XLOGFORMATTER_HPP_
37*cdf0e10cSrcweir #include <com/sun/star/logging/XCsvLogFormatter.hpp>
38*cdf0e10cSrcweir #endif
39*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LOGGING_XLOGFORMATTER_HPP_
40*cdf0e10cSrcweir #include <com/sun/star/logging/XLogFormatter.hpp>
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
43*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
44*cdf0e10cSrcweir #endif
45*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
46*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
47*cdf0e10cSrcweir #endif
48*cdf0e10cSrcweir /** === end UNO includes === **/
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #include <osl/thread.h>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir namespace logging
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     /** === begin UNO using === **/
62*cdf0e10cSrcweir     using ::com::sun::star::logging::XCsvLogFormatter;
63*cdf0e10cSrcweir     using ::com::sun::star::logging::XLogFormatter;
64*cdf0e10cSrcweir     using ::com::sun::star::uno::XComponentContext;
65*cdf0e10cSrcweir     using ::com::sun::star::uno::Reference;
66*cdf0e10cSrcweir     using ::com::sun::star::uno::Sequence;
67*cdf0e10cSrcweir     using ::com::sun::star::lang::XServiceInfo;
68*cdf0e10cSrcweir     using ::com::sun::star::uno::RuntimeException;
69*cdf0e10cSrcweir     using ::com::sun::star::logging::LogRecord;
70*cdf0e10cSrcweir     using ::com::sun::star::uno::XInterface;
71*cdf0e10cSrcweir     /** === end UNO using === **/
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     //= CsvFormatter - declaration
74*cdf0e10cSrcweir     //= formats for csv files as defined by RFC4180
75*cdf0e10cSrcweir     typedef ::cppu::WeakImplHelper2 <   XCsvLogFormatter
76*cdf0e10cSrcweir                                     ,   XServiceInfo
77*cdf0e10cSrcweir                                     >   CsvFormatter_Base;
78*cdf0e10cSrcweir     class CsvFormatter : public CsvFormatter_Base
79*cdf0e10cSrcweir     {
80*cdf0e10cSrcweir     public:
81*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL formatMultiColumn(const Sequence< ::rtl::OUString>& column_data) throw (RuntimeException);
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir         // XServiceInfo - static version
84*cdf0e10cSrcweir         static ::rtl::OUString SAL_CALL getImplementationName_static();
85*cdf0e10cSrcweir         static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
86*cdf0e10cSrcweir         static Reference< XInterface > Create( const Reference< XComponentContext >& context );
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     protected:
89*cdf0e10cSrcweir         CsvFormatter( const Reference< XComponentContext >& context );
90*cdf0e10cSrcweir         virtual ~CsvFormatter();
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir         // XCsvLogFormatter
93*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL getLogEventNo() throw (RuntimeException);
94*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL getLogThread() throw (RuntimeException);
95*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL getLogTimestamp() throw (RuntimeException);
96*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL getLogSource() throw (RuntimeException);
97*cdf0e10cSrcweir         virtual Sequence< ::rtl::OUString > SAL_CALL getColumnnames() throw (RuntimeException);
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir         virtual void SAL_CALL setLogEventNo( ::sal_Bool log_event_no ) throw (RuntimeException);
100*cdf0e10cSrcweir         virtual void SAL_CALL setLogThread( ::sal_Bool log_thread ) throw (RuntimeException);
101*cdf0e10cSrcweir         virtual void SAL_CALL setLogTimestamp( ::sal_Bool log_timestamp ) throw (RuntimeException);
102*cdf0e10cSrcweir         virtual void SAL_CALL setLogSource( ::sal_Bool log_source ) throw (RuntimeException);
103*cdf0e10cSrcweir         virtual void SAL_CALL setColumnnames( const Sequence< ::rtl::OUString>& column_names) throw (RuntimeException);
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir         // XLogFormatter
106*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getHead(  ) throw (RuntimeException);
107*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL format( const LogRecord& Record ) throw (RuntimeException);
108*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getTail(  ) throw (RuntimeException);
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         // XServiceInfo
111*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
112*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& service_name ) throw(RuntimeException);
113*cdf0e10cSrcweir         virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     private:
116*cdf0e10cSrcweir         ::comphelper::ComponentContext m_aContext;
117*cdf0e10cSrcweir         ::sal_Bool m_LogEventNo;
118*cdf0e10cSrcweir         ::sal_Bool m_LogThread;
119*cdf0e10cSrcweir         ::sal_Bool m_LogTimestamp;
120*cdf0e10cSrcweir         ::sal_Bool m_LogSource;
121*cdf0e10cSrcweir         ::sal_Bool m_MultiColumn;
122*cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::rtl::OUString > m_Columnnames;
123*cdf0e10cSrcweir     };
124*cdf0e10cSrcweir } // namespace logging
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir //= private helpers
127*cdf0e10cSrcweir namespace
128*cdf0e10cSrcweir {
129*cdf0e10cSrcweir     const sal_Unicode quote_char = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"")).toChar();
130*cdf0e10cSrcweir     const sal_Unicode comma_char = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")).toChar();
131*cdf0e10cSrcweir     const ::rtl::OUString dos_newline = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\r\n"));
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     inline bool needsQuoting(const ::rtl::OUString& str)
134*cdf0e10cSrcweir     {
135*cdf0e10cSrcweir         static const ::rtl::OUString quote_trigger_chars = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("\",\n\r"));
136*cdf0e10cSrcweir         sal_Int32 len = str.getLength();
137*cdf0e10cSrcweir         for(sal_Int32 i=0; i<len; i++)
138*cdf0e10cSrcweir             if(quote_trigger_chars.indexOf(str[i])!=-1)
139*cdf0e10cSrcweir                 return true;
140*cdf0e10cSrcweir         return false;
141*cdf0e10cSrcweir     };
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     inline void appendEncodedString(::rtl::OUStringBuffer& buf, const ::rtl::OUString& str)
144*cdf0e10cSrcweir     {
145*cdf0e10cSrcweir         if(needsQuoting(str))
146*cdf0e10cSrcweir         {
147*cdf0e10cSrcweir             // each double-quote will get replaced by two double-quotes
148*cdf0e10cSrcweir             buf.append(quote_char);
149*cdf0e10cSrcweir             const sal_Int32 buf_offset = buf.getLength();
150*cdf0e10cSrcweir             const sal_Int32 str_length = str.getLength();
151*cdf0e10cSrcweir             buf.append(str);
152*cdf0e10cSrcweir             // special treatment for the last character
153*cdf0e10cSrcweir             if(quote_char==str[str_length-1])
154*cdf0e10cSrcweir                 buf.append(quote_char);
155*cdf0e10cSrcweir             // iterating backwards because the index at which we insert wont be shifted
156*cdf0e10cSrcweir             // when moving that way.
157*cdf0e10cSrcweir             for(sal_Int32 i = str_length; i>=0; )
158*cdf0e10cSrcweir             {
159*cdf0e10cSrcweir                 i=str.lastIndexOf(quote_char, --i);
160*cdf0e10cSrcweir                 if(i!=-1)
161*cdf0e10cSrcweir                     buf.insert(buf_offset + i, quote_char);
162*cdf0e10cSrcweir             }
163*cdf0e10cSrcweir             buf.append(quote_char);
164*cdf0e10cSrcweir         }
165*cdf0e10cSrcweir         else
166*cdf0e10cSrcweir             buf.append(str);
167*cdf0e10cSrcweir     };
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString> initialColumns()
170*cdf0e10cSrcweir     {
171*cdf0e10cSrcweir         com::sun::star::uno::Sequence< ::rtl::OUString> result = ::com::sun::star::uno::Sequence< ::rtl::OUString>(1);
172*cdf0e10cSrcweir         result[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("message"));
173*cdf0e10cSrcweir         return result;
174*cdf0e10cSrcweir     };
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir //= CsvFormatter - implementation
178*cdf0e10cSrcweir namespace logging
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir     CsvFormatter::CsvFormatter( const Reference< XComponentContext >& context )
181*cdf0e10cSrcweir         :m_aContext( context ),
182*cdf0e10cSrcweir         m_LogEventNo(true),
183*cdf0e10cSrcweir         m_LogThread(true),
184*cdf0e10cSrcweir         m_LogTimestamp(true),
185*cdf0e10cSrcweir         m_LogSource(false),
186*cdf0e10cSrcweir         m_MultiColumn(false),
187*cdf0e10cSrcweir         m_Columnnames(initialColumns())
188*cdf0e10cSrcweir     { }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     CsvFormatter::~CsvFormatter()
191*cdf0e10cSrcweir     { }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     ::sal_Bool CsvFormatter::getLogEventNo() throw (RuntimeException)
194*cdf0e10cSrcweir     {
195*cdf0e10cSrcweir         return m_LogEventNo;
196*cdf0e10cSrcweir     }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     ::sal_Bool CsvFormatter::getLogThread() throw (RuntimeException)
199*cdf0e10cSrcweir     {
200*cdf0e10cSrcweir         return m_LogThread;
201*cdf0e10cSrcweir     }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir     ::sal_Bool CsvFormatter::getLogTimestamp() throw (RuntimeException)
204*cdf0e10cSrcweir     {
205*cdf0e10cSrcweir         return m_LogTimestamp;
206*cdf0e10cSrcweir     }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir     ::sal_Bool CsvFormatter::getLogSource() throw (RuntimeException)
209*cdf0e10cSrcweir     {
210*cdf0e10cSrcweir         return m_LogSource;
211*cdf0e10cSrcweir     }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir     Sequence< ::rtl::OUString > CsvFormatter::getColumnnames() throw (RuntimeException)
214*cdf0e10cSrcweir     {
215*cdf0e10cSrcweir         return m_Columnnames;
216*cdf0e10cSrcweir     }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir     void CsvFormatter::setLogEventNo(::sal_Bool log_event_no) throw (RuntimeException)
219*cdf0e10cSrcweir     {
220*cdf0e10cSrcweir         m_LogEventNo = log_event_no;
221*cdf0e10cSrcweir     }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     void CsvFormatter::setLogThread(::sal_Bool log_thread) throw (RuntimeException)
224*cdf0e10cSrcweir     {
225*cdf0e10cSrcweir         m_LogThread = log_thread;
226*cdf0e10cSrcweir     }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir     void CsvFormatter::setLogTimestamp(::sal_Bool log_timestamp) throw (RuntimeException)
229*cdf0e10cSrcweir     {
230*cdf0e10cSrcweir         m_LogTimestamp = log_timestamp;
231*cdf0e10cSrcweir     }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     void CsvFormatter::setLogSource(::sal_Bool log_source) throw (RuntimeException)
234*cdf0e10cSrcweir     {
235*cdf0e10cSrcweir         m_LogSource = log_source;
236*cdf0e10cSrcweir     }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir     void CsvFormatter::setColumnnames(const Sequence< ::rtl::OUString >& columnnames) throw (RuntimeException)
239*cdf0e10cSrcweir     {
240*cdf0e10cSrcweir         m_Columnnames = Sequence< ::rtl::OUString>(columnnames);
241*cdf0e10cSrcweir         m_MultiColumn = (m_Columnnames.getLength()>1);
242*cdf0e10cSrcweir     }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL CsvFormatter::getHead(  ) throw (RuntimeException)
245*cdf0e10cSrcweir     {
246*cdf0e10cSrcweir         ::rtl::OUStringBuffer buf;
247*cdf0e10cSrcweir         if(m_LogEventNo)
248*cdf0e10cSrcweir             buf.appendAscii("event no,");
249*cdf0e10cSrcweir         if(m_LogThread)
250*cdf0e10cSrcweir             buf.appendAscii("thread,");
251*cdf0e10cSrcweir         if(m_LogTimestamp)
252*cdf0e10cSrcweir             buf.appendAscii("timestamp,");
253*cdf0e10cSrcweir         if(m_LogSource)
254*cdf0e10cSrcweir             buf.appendAscii("class,method,");
255*cdf0e10cSrcweir         sal_Int32 columns = m_Columnnames.getLength();
256*cdf0e10cSrcweir         for(sal_Int32 i=0; i<columns; i++)
257*cdf0e10cSrcweir         {
258*cdf0e10cSrcweir             buf.append(m_Columnnames[i]);
259*cdf0e10cSrcweir             buf.append(comma_char);
260*cdf0e10cSrcweir         }
261*cdf0e10cSrcweir         buf.setLength(buf.getLength()-1);
262*cdf0e10cSrcweir         buf.append(dos_newline);
263*cdf0e10cSrcweir         return buf.makeStringAndClear();
264*cdf0e10cSrcweir     }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL CsvFormatter::format( const LogRecord& record ) throw (RuntimeException)
267*cdf0e10cSrcweir     {
268*cdf0e10cSrcweir         ::rtl::OUStringBuffer aLogEntry;
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir         if(m_LogEventNo)
271*cdf0e10cSrcweir         {
272*cdf0e10cSrcweir             aLogEntry.append( record.SequenceNumber );
273*cdf0e10cSrcweir             aLogEntry.append(comma_char);
274*cdf0e10cSrcweir         }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir         if(m_LogThread)
277*cdf0e10cSrcweir         {
278*cdf0e10cSrcweir             aLogEntry.append( record.ThreadID );
279*cdf0e10cSrcweir             aLogEntry.append(comma_char);
280*cdf0e10cSrcweir         }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir         if(m_LogTimestamp)
283*cdf0e10cSrcweir         {
284*cdf0e10cSrcweir             // ISO 8601
285*cdf0e10cSrcweir             char buffer[ 30 ];
286*cdf0e10cSrcweir             const size_t buffer_size = sizeof( buffer );
287*cdf0e10cSrcweir             snprintf( buffer, buffer_size, "%04i-%02i-%02iT%02i:%02i:%02i.%02i",
288*cdf0e10cSrcweir                 (int)record.LogTime.Year,
289*cdf0e10cSrcweir                 (int)record.LogTime.Month,
290*cdf0e10cSrcweir                 (int)record.LogTime.Day,
291*cdf0e10cSrcweir                 (int)record.LogTime.Hours,
292*cdf0e10cSrcweir                 (int)record.LogTime.Minutes,
293*cdf0e10cSrcweir                 (int)record.LogTime.Seconds,
294*cdf0e10cSrcweir                 (int)record.LogTime.HundredthSeconds );
295*cdf0e10cSrcweir             aLogEntry.appendAscii( buffer );
296*cdf0e10cSrcweir             aLogEntry.append(comma_char);
297*cdf0e10cSrcweir         }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir         if(m_LogSource)
300*cdf0e10cSrcweir         {
301*cdf0e10cSrcweir             appendEncodedString(aLogEntry, record.SourceClassName);
302*cdf0e10cSrcweir             aLogEntry.append(comma_char);
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir             appendEncodedString(aLogEntry, record.SourceMethodName);
305*cdf0e10cSrcweir             aLogEntry.append(comma_char);
306*cdf0e10cSrcweir         }
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir         // if the CsvFormatter has multiple columns set via setColumnnames(), the
309*cdf0e10cSrcweir         // message of the record is expected to be encoded with formatMultiColumn
310*cdf0e10cSrcweir         // if the CsvFormatter has only one column set, the message is expected not
311*cdf0e10cSrcweir         // to be encoded
312*cdf0e10cSrcweir         if(m_MultiColumn)
313*cdf0e10cSrcweir             aLogEntry.append(record.Message);
314*cdf0e10cSrcweir         else
315*cdf0e10cSrcweir             appendEncodedString(aLogEntry, record.Message);
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir         aLogEntry.append( dos_newline );
318*cdf0e10cSrcweir         return aLogEntry.makeStringAndClear();
319*cdf0e10cSrcweir     }
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL CsvFormatter::getTail(  ) throw (RuntimeException)
322*cdf0e10cSrcweir     {
323*cdf0e10cSrcweir         return ::rtl::OUString();
324*cdf0e10cSrcweir     }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL CsvFormatter::formatMultiColumn(const Sequence< ::rtl::OUString>& column_data) throw (RuntimeException)
327*cdf0e10cSrcweir     {
328*cdf0e10cSrcweir         sal_Int32 columns = column_data.getLength();
329*cdf0e10cSrcweir         ::rtl::OUStringBuffer buf;
330*cdf0e10cSrcweir         for(int i=0; i<columns; i++)
331*cdf0e10cSrcweir         {
332*cdf0e10cSrcweir             appendEncodedString(buf, column_data[i]);
333*cdf0e10cSrcweir             buf.append(comma_char);
334*cdf0e10cSrcweir         }
335*cdf0e10cSrcweir         buf.setLength(buf.getLength()-1);
336*cdf0e10cSrcweir         return buf.makeStringAndClear();
337*cdf0e10cSrcweir     }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir     ::sal_Bool SAL_CALL CsvFormatter::supportsService( const ::rtl::OUString& service_name ) throw(RuntimeException)
340*cdf0e10cSrcweir     {
341*cdf0e10cSrcweir         const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() );
342*cdf0e10cSrcweir         for (   const ::rtl::OUString* pServiceNames = aServiceNames.getConstArray();
343*cdf0e10cSrcweir                 pServiceNames != aServiceNames.getConstArray() + aServiceNames.getLength();
344*cdf0e10cSrcweir                 ++pServiceNames
345*cdf0e10cSrcweir             )
346*cdf0e10cSrcweir             if ( service_name == *pServiceNames )
347*cdf0e10cSrcweir                 return sal_True;
348*cdf0e10cSrcweir         return sal_False;
349*cdf0e10cSrcweir     }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL CsvFormatter::getImplementationName() throw(RuntimeException)
352*cdf0e10cSrcweir     {
353*cdf0e10cSrcweir         return getImplementationName_static();
354*cdf0e10cSrcweir     }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL CsvFormatter::getSupportedServiceNames() throw(RuntimeException)
357*cdf0e10cSrcweir     {
358*cdf0e10cSrcweir         return getSupportedServiceNames_static();
359*cdf0e10cSrcweir     }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL CsvFormatter::getImplementationName_static()
362*cdf0e10cSrcweir     {
363*cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.CsvFormatter" ) );
364*cdf0e10cSrcweir     }
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL CsvFormatter::getSupportedServiceNames_static()
367*cdf0e10cSrcweir     {
368*cdf0e10cSrcweir         Sequence< ::rtl::OUString > aServiceNames(1);
369*cdf0e10cSrcweir         aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.CsvFormatter" ) );
370*cdf0e10cSrcweir         return aServiceNames;
371*cdf0e10cSrcweir     }
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir     Reference< XInterface > CsvFormatter::Create( const Reference< XComponentContext >& context )
374*cdf0e10cSrcweir     {
375*cdf0e10cSrcweir         return *( new CsvFormatter( context ) );
376*cdf0e10cSrcweir     }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir     void createRegistryInfo_CsvFormatter()
379*cdf0e10cSrcweir     {
380*cdf0e10cSrcweir         static OAutoRegistration< CsvFormatter > aAutoRegistration;
381*cdf0e10cSrcweir     }
382*cdf0e10cSrcweir } // namespace logging
383