javacommons/utils/inc/logger.h
branchRCL_3
changeset 19 04becd199f91
child 23 98ccebc37403
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 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 * Description:
       
    15 * Logging component is used to record sequential error, warning and tracing
       
    16 * information. All components in Java package shall use either this c++
       
    17 * logger or Java logger to enable easier tracing for Java platform and
       
    18 * Java application developers.
       
    19 * The log files use UTF-8 encoding to enable usage of non-ASCII characters
       
    20 * in the log messages.
       
    21 *
       
    22 * The Logger has 6 levels of logging messages:
       
    23 *
       
    24 *  * EError, used when there is an error, for example installation fails.
       
    25 *  * EWarning, used when application installation / running is not interrupted,
       
    26 *              but installation/application is behaving incorrectly (e.g. not
       
    27 *              able to read opened file, not able to decode currupted image)
       
    28 *  * EInfoPrd, used in product high level tracing, e.g. what application has been
       
    29 *              started, which parameters has been passed to virtual machine,
       
    30 *              what is the URL accessed with HTTP stack. These messages
       
    31 *              must be understable without checking the Java platform
       
    32 *              implementation.
       
    33 *  * EInfo, used in high level tracing
       
    34 *  * EEntryLog, used to log function entries
       
    35 *  * EHeavyLoad, used in detailed tracing
       
    36 *
       
    37 *  EError, EWarning and EInfoPrd are enabled both in debug and release (product) builds
       
    38 *  EError, EWarning, EInfoPrd and EInfo are enabled in debug builds.
       
    39 *  EEntryLog and EHeavyLoad shall be enabled from this file
       
    40 *
       
    41 * Note that the logs are created in Symbian to two directories
       
    42 * C:\logs\java  (the most important log files,
       
    43 *                error level log entries can be found here)
       
    44 * C:\logs\java\full (create this directory and define
       
    45 *                    JAVA_LOGGER_ON when you want to enable full logging)
       
    46 *
       
    47 */
       
    48 
       
    49 
       
    50 #ifndef LOGGER_H
       
    51 #define LOGGER_H
       
    52 
       
    53 #include <pthread.h>
       
    54 #include <string>
       
    55 #include <vector>
       
    56 #include "javaosheaders.h"
       
    57 #include "javacommonutils.h"
       
    58 
       
    59 #ifdef _DEBUG
       
    60 #define  JAVA_LOGGER_ON
       
    61 #endif // _DEBUG
       
    62 
       
    63 
       
    64 //#define  JAVA_LOGGER_ON
       
    65 //#define  JAVA_HEAVY_LOGGER_ON
       
    66 #define  J_LOG_DATE_TIME_ENABLED            //add date and time to log
       
    67 #define  J_LOG_MILLISEC_ENABLED             //add time in millisec to log
       
    68 #define  J_LOG_PID_ENABLED                  //add time pid to log
       
    69 
       
    70 //#define J_LOG_ALL_LOGS_TO_SINGLE_FILE       //log to a single file
       
    71 
       
    72 
       
    73 /**
       
    74  * List of component IDs.
       
    75  * Logger uses these IDs to identify source of tracing information.
       
    76  * Developers shall add new component IDs to the end of this list.
       
    77  * Keep the list in sync with the java side logging component
       
    78  * javacommons\utils\javasrc\com\nokia\mj\impl\utils\Logger.java
       
    79  */
       
    80 enum TComponents
       
    81 {
       
    82     EJavaCaptain            = 1,
       
    83     EJavaRuntime,       //  = 2
       
    84     EJavaComms,         //  = 3
       
    85     EAppRecognizer,     //  = 4
       
    86     EMidpRms,           //  = 5
       
    87     EUtils,             //  = 6
       
    88     EJavaUI,            //  = 7
       
    89     EJavaPush,          //  = 8
       
    90     EJVM,               //  = 9
       
    91     EGcf,               //  =10
       
    92     EJavaStorage,       //  =11
       
    93     EJavaInstaller,     //  =12
       
    94     EJavaFile,          //  =13
       
    95     ESOCKET,            //  =14
       
    96     EWMA,               //  =15
       
    97     EPim,               //  =16
       
    98     EJavaPreinstaller,  //  =17
       
    99     ETckRunner,         //  =18
       
   100     EJavaBluetooth,     //  =19
       
   101     EJavaSecurity,      //  =20
       
   102     EGcfProtocols,      //  =21
       
   103     EJavaMMAPI,         //  =22
       
   104     ESATSA,             //  =23
       
   105     EJavaLocation,      //  =24
       
   106     EBackup,            //  =25
       
   107     EJavaSystemAMS,     //  =26
       
   108     EJavaIapInfo,       //  =27
       
   109     EJavaContactless,   //  =28
       
   110     EJavaConverters,    //  =29
       
   111     EMidp2CenrepWrapper,//  =30
       
   112     EJavaWebServices,   //  =31
       
   113     EJavaGlobalInd,     //  =32
       
   114     ESensor,            //  =33
       
   115     EDebugApi,          //  =34
       
   116     EJavaAppMngrPlugin, //  =35
       
   117     EJavaBroadcast,     //  =36
       
   118     // add id of new components here
       
   119 };
       
   120 
       
   121 /**
       
   122  * Logger could store tracing information from different components
       
   123  * to a single file or create separate logging file for each component
       
   124  * (to log to single file enable J_LOG_ALL_LOGS_TO_SINGLE_FILE macro).
       
   125  *
       
   126  * This structure contains name of logging file for each component and
       
   127  * component's nickname which will be used when all logging info is stored
       
   128  * in a single file.
       
   129  */
       
   130 const struct
       
   131 {
       
   132     const char* log_file;
       
   133     const char* name;
       
   134 } component_list[] =
       
   135 {
       
   136     {"JavaLog.log",          NULL            },       // When all logs are directed to single log file
       
   137 
       
   138     {"JavaCaptain.log",      "[JavaCaptain]" },       // EJavaCaptain
       
   139     {"JavaRuntime.log",      "[JavaRuntime]" },       // EJavaRuntime
       
   140     {"JavaComms.log",        "[ JavaComms ]" },       // EJavaComms
       
   141     {"AppRecognizer.log",    "[AppRecognz ]" },       // EAppRecognizer
       
   142     {"JavaRms.log",          "[  JavaRms  ]" },       // EMidpRms
       
   143     {"JavaUtils.log",        "[ JavaUtils ]" },       // EUtils
       
   144     {"JavaUi.log",           "[  JavaUi   ]" },       // EJavaUi
       
   145     {"JavaPush.log",         "[ JavaPush  ]" },       // EJavaPush
       
   146     {"JavaVM.log",           "[  JavaVM   ]" },       // EJVM
       
   147     {"JavaGcf.log",          "[  JavaGcf  ]" },       // EGcf
       
   148     {"JavaStorage.log",      "[JavaStorage]" },       // EJavaStorage
       
   149     {"JavaInstaller.log",    "[JavaInstall]" },       // EJavaInstaller
       
   150     {"JavaFile.log",         "[ JavaFile  ]" },       // EJavaFile
       
   151     {"JavaSocket.log",       "[ SOCKET  ]" },         // ESOCKET
       
   152     {"JavaWma.log",          "[ WMA       ]" },       // EWMA
       
   153     {"JavaPim.log",          "[ PIM       ]" },       // EPIM
       
   154     {"JavaPreinstaller.log", "[JavaPreinstaller]" },  // EJavaPreinstaller
       
   155     {"JavaTckRunner.log",    "[ TckRunner ]" },       // ETckRunner
       
   156     {"JavaBluetooth.log",    "[JavaBluetooth]" },     // EJavaBluetooth
       
   157     {"JavaSecurity.log",     "[ JavaSecurity ]" },    // EJavaSecurity
       
   158     {"JavaGcfProtocols.log", "[JavaGcfProtocols ]" }, // EGcfProtocols
       
   159     {"JavaMMAPI.log",        "[ MMAPI ]"},            // EJavaMMAPI
       
   160     {"JavaSatsa.log",        "[JavaSatsa]" },         // ESATSA
       
   161     {"JavaLocation.log",     "[ JavaLocation }"},     // ELocation
       
   162     {"JavaBackup.log",       "[ JavaBackup ]"},       // EJavaBackup
       
   163     {"JavaSystemAMS.log",    "[JavaSystemAMS]"},      // EJavaSystemAMS
       
   164     {"JavaIapInfo.log",      "[ JavaIapInfo ]"},      // EJavaIapInfo
       
   165     {"JavaContactless.log",  "[JavaContactless]"},    // EJavaContactless
       
   166     {"JavaConverters.log",   "[JavaConverters]"},     // EJavaConverters
       
   167     {"JavaCenrepWrapper.log","[JavaCenrepWrapper]"},  // EMidp2CenrepWrapper
       
   168     {"JavaWebServices.log",  "[JavaWebServices]"},    // EJavaWebServices
       
   169     {"JavaGlobalInd.log",    "[JavaGlobalInd]"},      // EJavaGlobalInd
       
   170     {"JavaSensor.log",       "[JavaSensor   ]"},      // EJavaSensor
       
   171     {"JavaDebugApi.log",     "[JavaDebugApi]"},       // EDebugApi
       
   172     {"JavaAppMngrPlugin.log","[JavaAppMngrPlugin]"},  // EJavaAppMngrPlugin
       
   173     {"JavaBroadcast.log",    "[JavaBroadcast]"},      // EJavaBroadcast
       
   174     // add new component file name and nickname here
       
   175 };
       
   176 
       
   177 /**
       
   178  * logging levels
       
   179  */
       
   180 enum TLogLevels
       
   181 {
       
   182 
       
   183     /**
       
   184      * logging disabled
       
   185      */
       
   186     ENoLog = 0,
       
   187 
       
   188     /**
       
   189      * Use ELOG(s) macros to log errors.
       
   190      * Activated both in debug and release builds.
       
   191      */
       
   192     EError = 0x1,
       
   193 
       
   194     /**
       
   195      * Use WLOG(s) macros to log warnigs.
       
   196      * Activated both in debug and release builds.
       
   197      */
       
   198     EWarning = 0x2,
       
   199 
       
   200     /**
       
   201      * Used for high level tracing. The logging level is enabled
       
   202      * both in release (products) and debug builds (emulators).
       
   203      * Use PLOG(s) macros.
       
   204      * @see logging level EInfo
       
   205      */
       
   206     EInfoPrd = 0x4,
       
   207 
       
   208     /**
       
   209      * Used for debug tracing information. Could be activated
       
   210      * in debug builds, disabled for release builds completely.
       
   211      * Use ILOG(s) macros.
       
   212      */
       
   213     EInfo = 0x8,
       
   214 
       
   215     /**
       
   216     * Used for function entries. Could be activated
       
   217     * in debug builds with JAVA_HEAVY_LOGGER_ON flag.
       
   218     * Use JELOG(s) macros.
       
   219     */
       
   220     EEntryLog = 0x10,
       
   221 
       
   222     /**
       
   223      * Used for heavy tracing, could generate huge log files.
       
   224      * Activated by JAVA_HEAVY_LOGGER_ON compilation flag.
       
   225      * Use HLOG(s) macros.
       
   226      */
       
   227     EInfoHeavyLoad = 0x20,
       
   228 };
       
   229 
       
   230 
       
   231 // ---------------------------------------------------------
       
   232 //    Logging macros
       
   233 // ---------------------------------------------------------
       
   234 
       
   235 #ifdef __SYMBIAN32__
       
   236 #define J_LOG_USE_RLOGGER_ENABLED //use Symbian logger for output
       
   237 #endif
       
   238 
       
   239 /**
       
   240  * Macros for Error level logging are always enabled.
       
   241  *
       
   242  * params:
       
   243  *   component - component id from TComponents enum
       
   244  *   str, a, b, c, d - string and up to 4 parameters in printf() family functions style
       
   245  */
       
   246 #define ELOG(component, str)                    java::util::Logger::Log(component, EError, str)
       
   247 #define ELOG1(component, str, a)                java::util::Logger::Log(component, EError, str, a)
       
   248 #define ELOG2(component, str, a, b)             java::util::Logger::Log(component, EError, str, a, b)
       
   249 #define ELOG3(component, str, a, b, c)          java::util::Logger::Log(component, EError, str, a, b, c)
       
   250 #define ELOG4(component, str, a, b, c, d)       java::util::Logger::Log(component, EError, str, a, b, c, d)
       
   251 
       
   252 #define ELOG1WSTR(component, str, wstr)         { char* msg =  java::util::JavaCommonUtils::wstringToUtf8(wstr); \
       
   253                                                   java::util::Logger::Log(component, EError, str, msg); \
       
   254                                                   delete[] msg; }
       
   255 
       
   256 /**
       
   257  * Macros for Warning level logging are always enabled.
       
   258  *
       
   259  * params:
       
   260  *   component - component id from TComponents enum
       
   261  *   str, a, b, c, d - string and up to 4 parameters in printf() family functions style
       
   262  */
       
   263 #define WLOG(component, str)                    java::util::Logger::Log(component, EWarning, str)
       
   264 #define WLOG1(component, str, a)                java::util::Logger::Log(component, EWarning, str, a)
       
   265 #define WLOG2(component, str, a, b)             java::util::Logger::Log(component, EWarning, str, a, b)
       
   266 #define WLOG3(component, str, a, b, c)          java::util::Logger::Log(component, EWarning, str, a, b, c)
       
   267 #define WLOG4(component, str, a, b, c, d)       java::util::Logger::Log(component, EWarning, str, a, b, c, d)
       
   268 
       
   269 #define WLOG1WSTR(component, str, wstr)         { char* msg =  java::util::JavaCommonUtils::wstringToUtf8(wstr); \
       
   270                                                   java::util::Logger::Log(component, EWarning, str, msg); \
       
   271                                                   delete[] msg; }
       
   272 
       
   273 /**
       
   274  * Macros for Info level logging ending to the products.
       
   275  * These are always enabled.
       
   276  *
       
   277  * params:
       
   278  *   component - component id from TComponents enum
       
   279  *   str, a, b, c, d - string and up to 4 parameters in printf() family functions style
       
   280  */
       
   281 #define PLOG(component, str)                    java::util::Logger::Log(component, EInfoPrd, str)
       
   282 #define PLOG1(component, str, a)                java::util::Logger::Log(component, EInfoPrd, str, a)
       
   283 #define PLOG2(component, str, a, b)             java::util::Logger::Log(component, EInfoPrd, str, a, b)
       
   284 #define PLOG3(component, str, a, b, c)          java::util::Logger::Log(component, EInfoPrd, str, a, b, c)
       
   285 #define PLOG4(component, str, a, b, c, d)       java::util::Logger::Log(component, EInfoPrd, str, a, b, c, d)
       
   286 
       
   287 #define PLOG1WSTR(component, str, wstr)         { char* msg =  java::util::JavaCommonUtils::wstringToUtf8(wstr); \
       
   288                                                   java::util::Logger::Log(component, EInfoPrd, str, msg); \
       
   289                                                   delete[] msg; }
       
   290 
       
   291 #ifdef JAVA_LOGGER_ON
       
   292 /**
       
   293  * Tracing macros for EInfo level logging. There are always enabled in debug builds.
       
   294  *
       
   295  * params:
       
   296  *   component - component id from TComponents enum
       
   297  *   str, a, b, c, d - string and up to 4 parameters in printf() family functions style
       
   298  */
       
   299 #define ILOG(component, str)                    java::util::Logger::Log(component, EInfo, str)
       
   300 #define ILOG1(component, str, a)                java::util::Logger::Log(component, EInfo, str, a)
       
   301 #define ILOG2(component, str, a, b)             java::util::Logger::Log(component, EInfo, str, a, b)
       
   302 #define ILOG3(component, str, a, b, c)          java::util::Logger::Log(component, EInfo, str, a, b, c)
       
   303 #define ILOG4(component, str, a, b, c, d)       java::util::Logger::Log(component, EInfo, str, a, b, c, d)
       
   304 #define ILOG1WSTR(component, level, str, wstr)        { char* msg =  java::util::JavaCommonUtils::wstringToUtf8(wstr); \
       
   305                                                       java::util::Logger::Log(component, EInfo, str, msg); \
       
   306                                                       delete[] msg; }
       
   307 
       
   308 #else /* JAVA_LOGGER_ON */
       
   309 
       
   310 #define ILOG(component, str)
       
   311 #define ILOG1(component, str, a)
       
   312 #define ILOG2(component, str, a, b)
       
   313 #define ILOG3(component, str, a, b, c)
       
   314 #define ILOG4(component, str, a, b, c, d)
       
   315 
       
   316 #define ILOG1WSTR(component, level, str, wstr)
       
   317 
       
   318 #endif /* JAVA_LOGGER_ON */
       
   319 
       
   320 
       
   321 #ifdef JAVA_HEAVY_LOGGER_ON
       
   322 /**
       
   323  * Tracing macros to label entering and exiting points of C++ function.
       
   324  *
       
   325  * These macros could be placed in the begining of the function body and they will
       
   326  * automatically generate tracing information when function exit.
       
   327  * activated by JAVA_HEAVY_LOGGER_ON compilation flag.
       
   328  *
       
   329  * params:
       
   330  *   component - component id from TComponents enum
       
   331  *   level - tracing level from TLogLevels enum, EEntry by default
       
   332  *   str - tracing info, type char*, name and signature of function by default
       
   333  *
       
   334  */
       
   335 #define JELOG(component, str)                   java::util::TEntryExitLog _x_(component, str)
       
   336 #define JELOG2(component)                       java::util::TEntryExitLog _x_(component, __PRETTY_FUNCTION__)
       
   337 #define JELOG3(component, level, str)           java::util::TEntryExitLog _x_(component, level, str)
       
   338 #define JELOG4(component, level)                java::util::TEntryExitLog _x_(component, level, __PRETTY_FUNCTION__)
       
   339 
       
   340 #else /* JAVA_HEAVY_LOGGER_ON */
       
   341 
       
   342 #define JELOG(component, str)
       
   343 #define JELOG2(component)
       
   344 #define JELOG3(component, level, str)
       
   345 #define JELOG4(component, level)
       
   346 
       
   347 #endif /* JAVA_HEAVY_LOGGER_ON */
       
   348 
       
   349 
       
   350 #ifdef JAVA_HEAVY_LOGGER_ON
       
   351 /**
       
   352  * Tracing macros to heavy logging.
       
   353  *
       
   354  * Log can be activated by JAVA_HEAVY_LOGGER_ON compilation flag.
       
   355  *
       
   356  * params:
       
   357  *   component - component id from TComponents enum
       
   358  *   str - tracing info, type char*, name and signature of function by default
       
   359  *
       
   360  */
       
   361 #define HLOG(component, str)                    java::util::Logger::Log(component, EInfoHeavyLoad, str)
       
   362 #define HLOG1(component, str, a)                java::util::Logger::Log(component, EInfoHeavyLoad, str, a)
       
   363 #define HLOG2(component, str, a, b)             java::util::Logger::Log(component, EInfoHeavyLoad, str, a, b)
       
   364 #define HLOG3(component, str, a, b, c)          java::util::Logger::Log(component, EInfoHeavyLoad, str, a, b, c)
       
   365 #define HLOG4(component, str, a, b, c, d)       java::util::Logger::Log(component, EInfoHeavyLoad, str, a, b, c, d)
       
   366 
       
   367 #else /* JAVA_HEAVY_LOGGER_ON */
       
   368 
       
   369 #define HLOG(component, level, str)
       
   370 #define HLOG1(component, level, str, a)
       
   371 #define HLOG2(component, level, str, a, b)
       
   372 #define HLOG3(component, level, str, a, b, c)
       
   373 #define HLOG4(component, level, str, a, b, c, d)
       
   374 
       
   375 #endif /* JAVA_HEAVY_LOGGER_ON */
       
   376 
       
   377 #ifdef JAVA_LOGGER_ON
       
   378 /**
       
   379  * Old tracing macros for EInfo and EInfoHeavyLoad level logging.
       
   380  * Please use ILOG and HLOG macros in new code.
       
   381  *
       
   382  * params:
       
   383  *   component - component id from TComponents enum
       
   384  *   level - tracing level from TLogLevels enum (EInfo or EInfoHeavyLoad)
       
   385  *   str, a, b, c, d - string and up to 4 parameters in printf() family functions style
       
   386  */
       
   387 #define LOG(component, level, str)                    java::util::Logger::Log(component, level, str)
       
   388 #define LOG1(component, level, str, a)                java::util::Logger::Log(component, level, str, a)
       
   389 #define LOG2(component, level, str, a, b)             java::util::Logger::Log(component, level, str, a, b)
       
   390 #define LOG3(component, level, str, a, b, c)          java::util::Logger::Log(component, level, str, a, b, c)
       
   391 #define LOG4(component, level, str, a, b, c, d)       java::util::Logger::Log(component, level, str, a, b, c, d)
       
   392 
       
   393 #define LOG1WSTR(component, level, str, wstr)        { char* msg =  java::util::JavaCommonUtils::wstringToUtf8(wstr); \
       
   394                                                       java::util::Logger::Log(component, level, str, msg); \
       
   395                                                       delete[] msg; }
       
   396 
       
   397 #else /* JAVA_LOGGER_ON */
       
   398 
       
   399 #define LOG(component, level, str)
       
   400 #define LOG1(component, level, str, a)
       
   401 #define LOG2(component, level, str, a, b)
       
   402 #define LOG3(component, level, str, a, b, c)
       
   403 #define LOG4(component, level, str, a, b, c, d)
       
   404 
       
   405 #define LOG1WSTR(component, level, str, wstr)
       
   406 
       
   407 #endif /* JAVA_LOGGER_ON */
       
   408 
       
   409 
       
   410 #ifndef J_LOG_USE_RLOGGER_ENABLED
       
   411 #if defined(__SYMBIAN32__) && !defined(__WINSCW__)
       
   412 const int  MAX_LOG_FILE_SIZE = 1024*1024*2;    // 2Mb max size of log file
       
   413 #else
       
   414 const int  MAX_LOG_FILE_SIZE = 1024*1024*16;    // 16Mb max size of log file
       
   415 #endif
       
   416 #endif
       
   417 
       
   418 
       
   419 namespace java
       
   420 {
       
   421 namespace util
       
   422 {
       
   423 
       
   424 // ---------------------------------------------------------
       
   425 //    TEntryExitLog class
       
   426 //    Logs entry and exit message whenever instantiated in a method
       
   427 // ---------------------------------------------------------
       
   428 class TEntryExitLog
       
   429 {
       
   430 
       
   431 public:
       
   432 
       
   433     /**
       
   434      * Logs entry message in a function
       
   435      *
       
   436      * @param aComponent the code of a user component
       
   437      * @param aMethod the name of a user method
       
   438      */
       
   439     OS_IMPORT TEntryExitLog(TComponents component,
       
   440                             const char* method_name);
       
   441 
       
   442     /**
       
   443      * Logs entry message in a function
       
   444      *
       
   445      * @param aComponent the code of a user component
       
   446      * @param aMethod the name of a user method
       
   447      */
       
   448     OS_IMPORT TEntryExitLog(TComponents component,
       
   449                             int         log_level,
       
   450                             const char* method_name);
       
   451 
       
   452     /**
       
   453      * Logs exit message when a functions exited
       
   454      */
       
   455     OS_IMPORT ~TEntryExitLog();
       
   456 
       
   457 private:
       
   458     void init();
       
   459 
       
   460 private:
       
   461     static const char KMethodIn[];
       
   462     static const char KMethodOut[];
       
   463 
       
   464     TComponents          i_component;
       
   465     int                  i_log_level;
       
   466     const char*          i_method_name;
       
   467 
       
   468 };
       
   469 
       
   470 
       
   471 // ---------------------------------------------------------
       
   472 //    Logger class
       
   473 //    Write log messages to corresponding files
       
   474 // ---------------------------------------------------------
       
   475 class Logger
       
   476 {
       
   477 
       
   478 public:
       
   479     /**
       
   480      * Check if logging is enabled
       
   481      *
       
   482      * @return true if log folder exists, otherwise false.
       
   483      * Checking up the folder is made only at the first call
       
   484      */
       
   485     static bool LogNeeded();
       
   486 
       
   487     /**
       
   488      * Log level can be read with this method.
       
   489      *
       
   490      * @return the current log level
       
   491      */
       
   492     static int GetLogLevel();
       
   493 
       
   494     /**
       
   495      * Formats and writes log message to file
       
   496      * @param component - id of a logging component
       
   497      * @param level - logging level
       
   498      * @param format_str - C string that contains the text to be written to the log.
       
   499      *                     It can optionally contain embedded format tags (in printf() family functions style ) that are
       
   500      *                     replaced by the values specified in subsequent additional arguments and formatted as requested
       
   501      */
       
   502     OS_IMPORT static void Log(TComponents component, TLogLevels level, const char* format_str, ...);
       
   503 
       
   504 private:
       
   505 
       
   506     /**
       
   507      * prints log info to file
       
   508      * @param txt -  C string to be printed to log
       
   509      * @param index - index of log file
       
   510      */
       
   511     static void Print(const char* txt, int index);
       
   512 
       
   513 #ifndef J_LOG_USE_RLOGGER_ENABLED
       
   514 
       
   515     /**
       
   516      * Returns descriptor of opened file by index, opens it if it wasn't opened before
       
   517      * @param index - index of file in i_file_descriptors table
       
   518      * @return descriptor of opened file
       
   519      */
       
   520     static int GetFileDescriptor(int index);
       
   521 
       
   522     /**
       
   523      * table of file descriptors
       
   524      */
       
   525     static std::vector<int> i_file_descriptors;
       
   526 
       
   527 #endif //J_LOG_USE_RLOGGER_ENABLED
       
   528 
       
   529     static const char KErrorString[];
       
   530     static const char KWarningString[];
       
   531     static const char KInfoString[];
       
   532     static const char KDebugString[];
       
   533 
       
   534     static const int  DES_FILE_CLOSED;
       
   535     static const int  DES_FILE_OVERFLOW;
       
   536 
       
   537 };
       
   538 
       
   539 } //end namespace util
       
   540 } //end namespace java
       
   541 
       
   542 #endif // LOGGER_H