filemanager/src/inc/fmlogger.h
branchRCL_3
changeset 21 65326cf895ed
parent 20 491b3ed49290
child 22 f5c50b8af68c
equal deleted inserted replaced
20:491b3ed49290 21:65326cf895ed
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  * 
       
    12  * Contributors:
       
    13  *
       
    14  * 
       
    15  * Description:
       
    16  *     The header file of logger
       
    17  */
       
    18 #ifndef FMLOGGER_H
       
    19 #define FMLOGGER_H
       
    20 
       
    21 #define FMLOG_PATH QString( "C:\\data\\fileman.txt" )
       
    22 
       
    23 #include <QString>
       
    24 #include <QFile>
       
    25 #include <QTextStream>
       
    26 #include <QDateTime>
       
    27 
       
    28 #ifdef _DEBUG_LOG_ENABLE_
       
    29     #define FM_LOG(str) FmLogger::log( str );
       
    30 #else
       
    31     #define FM_LOG(str)
       
    32 #endif
       
    33 
       
    34 class FmLogger
       
    35 {
       
    36 public:
       
    37 
       
    38     static bool log( const QString &log )
       
    39     {
       
    40 #ifdef _DEBUG_LOG_ENABLE_
       
    41         QString logStr( QDateTime::currentDateTime().toString("hh:mm:ss:zzz") + " " + log + "\r\n" );    
       
    42         QFile file( FMLOG_PATH );
       
    43         if ( !file.open( QIODevice::WriteOnly | QIODevice::Append ) )
       
    44         {
       
    45             return false;
       
    46         }
       
    47         QTextStream out( &file );
       
    48         out << logStr;
       
    49 #else
       
    50         Q_UNUSED( log );
       
    51 #endif
       
    52         return true;
       
    53     }
       
    54 };
       
    55 
       
    56 #endif