LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/logging - logrecord.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 15 0.0 %
Date: 2012-12-27 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "logrecord.hxx"
      21             : 
      22             : #include <osl/time.h>
      23             : #include <osl/thread.h>
      24             : #include <osl/diagnose.h>
      25             : 
      26             : //........................................................................
      27             : namespace logging
      28             : {
      29             : //........................................................................
      30             : 
      31             :     /** === begin UNO using === **/
      32             :     using ::com::sun::star::logging::LogRecord;
      33             :     using ::com::sun::star::util::DateTime;
      34             :     /** === end UNO using === **/
      35             : 
      36             :     //====================================================================
      37             :     //= helper
      38             :     //====================================================================
      39             :     //--------------------------------------------------------------------
      40             :     namespace
      41             :     {
      42             :         /** returns a string representation of the current thread
      43             : 
      44             :             @todo
      45             :                 We need a way to retrieve the current UNO thread ID as string,
      46             :                 which is issue #i77342#
      47             :         */
      48           0 :         ::rtl::OUString getCurrentThreadID()
      49             :         {
      50           0 :             oslThreadIdentifier nThreadID( osl_getThreadIdentifier( NULL ) );
      51           0 :             return ::rtl::OUString::valueOf( (sal_Int64)nThreadID );
      52             :         }
      53             :     }
      54             : 
      55             :     //--------------------------------------------------------------------
      56           0 :     LogRecord createLogRecord( const ::rtl::OUString& _rLoggerName, const ::rtl::OUString& _rClassName,
      57             :         const ::rtl::OUString& _rMethodName, const ::rtl::OUString& _rMessage,
      58             :         sal_Int32 _nLogLevel, oslInterlockedCount _nEventNumber )
      59             :     {
      60             :         TimeValue aTimeValue;
      61           0 :         osl_getSystemTime( &aTimeValue );
      62             : 
      63             :         oslDateTime aDateTime;
      64           0 :         OSL_VERIFY( osl_getDateTimeFromTimeValue( &aTimeValue, &aDateTime ) );
      65             : 
      66           0 :         DateTime aTimeStamp;
      67           0 :         aTimeStamp.Year = aDateTime.Year;
      68           0 :         aTimeStamp.Month = aDateTime.Month;
      69           0 :         aTimeStamp.Day = aDateTime.Day;
      70           0 :         aTimeStamp.Hours = aDateTime.Hours;
      71           0 :         aTimeStamp.Minutes = aDateTime.Minutes;
      72           0 :         aTimeStamp.Seconds = aDateTime.Seconds;
      73           0 :         aTimeStamp.HundredthSeconds = ::sal::static_int_cast< sal_Int16 >( aDateTime.NanoSeconds / 10000000 );
      74             : 
      75             :         return LogRecord(
      76             :             _rLoggerName,
      77             :             _rClassName,
      78             :             _rMethodName,
      79             :             _rMessage,
      80             :             aTimeStamp,
      81             :             _nEventNumber,
      82             :             getCurrentThreadID(),
      83             :             _nLogLevel
      84           0 :         );
      85             :     }
      86             : 
      87             : //........................................................................
      88             : } // namespace logging
      89             : //........................................................................
      90             : 
      91             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10