common/inc/Logger.h
changeset 0 c316ab048e9d
equal deleted inserted replaced
-1:000000000000 0:c316ab048e9d
       
     1 /*
       
     2  * Name        : Logger.h
       
     3  * Description : 
       
     4  * Project     : This file is part of OpenMAR, an Open Mobile Augmented Reality browser
       
     5  * Website     : http://OpenMAR.org
       
     6  *
       
     7  * Copyright (c) 2010 David Caabeiro
       
     8  *
       
     9  * All rights reserved. This program and the accompanying materials are made available 
       
    10  * under the terms of the Eclipse Public License v1.0 which accompanies this 
       
    11  * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
       
    12  *
       
    13  */
       
    14 
       
    15 #ifndef LOGGER_H_
       
    16 #define LOGGER_H_
       
    17 
       
    18 #include <f32file.h>
       
    19 
       
    20 #if defined(__DEBUG__)
       
    21 
       
    22 #define LOGCLOSE                CLogger::Close();
       
    23 #define LOGARG(text,param...)   { _LIT8(KText, text); CLogger::Write(KText, param); }
       
    24 #define LOGTXT(text)            { _LIT8(KText, text); CLogger::Write(static_cast<const TDesC8&>(KText)); }
       
    25 
       
    26 #else
       
    27 
       
    28 #define LOGCLOSE
       
    29 #define LOGARG
       
    30 #define LOGTXT
       
    31 
       
    32 #endif
       
    33 
       
    34 class CLogger : public CBase
       
    35 {
       
    36 public:
       
    37     static void Write(const TDesC8& aText);
       
    38     static void Write(TRefByValue<const TDesC8> aFmt, ...);
       
    39 
       
    40     static void Close();
       
    41 
       
    42 protected:
       
    43     static CLogger& InstanceL();
       
    44 
       
    45     void ConstructL();
       
    46     ~CLogger();
       
    47 
       
    48     void DoWrite(const TDesC8& aText);
       
    49 
       
    50 private:
       
    51     RFs   iFs;
       
    52     RFile iFile;
       
    53 
       
    54     TBuf8<1024> iBuffer;
       
    55 };
       
    56 
       
    57 #endif