⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.h

📁 270的linux说明
💻 H
字号:
/*

Copyright (c) 2008, Intel Corporation. 

All rights reserved.

 

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:


    * Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation and/or 
other materials provided with the distribution.

    * Neither the name of Intel Corporation nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.

*/#ifndef _LOG_H#define _LOG_H#include "inc/framework/win2linux.h"#include "inc/framework/basetypes.h"#include <stdio.h>           #include <string>           // stl stringsusing namespace std;// Some useful Log Levels#define LOG_NONE             0           // Don't log anything#define LOG_FATAL_ERROR      1           // Fatal errors#define LOG_HARD_ERROR       2           // Bad but not fatal errors#define LOG_SOFT_ERROR       4           // Not so bad errors#define LOG_INFORMATIONAL    8           // Information only, not an error#define LOG_DEBUG_BANDWIDTH  16          // Messages output by the Bandwidth components#define LOG_DEBUG_CONTEXT	 32          // Messages used for Context debugging #define LOG_DEBUG_DEVICE     64          // Messages used for device debugging#define LOG_DEBUG_PROVIDER   128         // Messages used for provider debugging #define LOG_DEBUG_FRAMEWORK  256         // Messages used for framework/base class debugging#define LOG_DEBUG_IPC        512         // Messages used for IPC (COM) debugging#define LOG_ALL              ULONG_MAX   // Log everything#define LOG_DEBUG_ALL LOG_DEBUG_BANDWIDTH | LOG_DEBUG_CONTEXT | LOG_DEBUG_DEVICE | LOG_DEBUG_PROVIDER | LOG_DEBUG_FRAMEWORK | LOG_DEBUG_IPC// SCR #614#define LOG_REG_KEY IntelMobileText("Intel(R) Mobile Platform SDK")/////////////////////////////////////////////////////////////////////////////// CLASS: CLog//          PURPOSE: Logs messages to a file in a thread-safe,//                   multi-process safe manner.// MEMBER FUNCTIONS://// LogV - Logs a variable message string//// operator() - Logs a variable message string//// RegisterLogfile - Registers the log file with the log class//// SetLogLevel - Sets the log level//// SetPrintStderr - Sets flag to determine whether or not to print messages//                  to stderr./////////////////////////////////////////////////////////////////////////////////extern void EnterCriticalSectionLog();//extern void LeaveCriticalSectionLog();class RegistryIO;class  CLog{protected:    RegistryIO*  m_pRegistryIO;                    // Registry IO utility class    HANDLE       m_hRegChangeEvent;                // Handle to the registry change event    HANDLE       m_hMutex;                         // Handle to the mutex for the logfile    FILE*        m_fp;                             // file pointer for the logfile    DWORD        m_logLevel;                       // Logging level for this instance of a log object    bool         m_bStderr;                        // If TRUE, messages are output to stderr    IntelMobileString      m_sPrefix;                        // String to prefix each entry with.    IntelMobileString      m_sLogFileName;                   // Current file name. Defaults to 'Log.log'.    IntelMobileString      m_sBackupName;                    // Name of the last backup file, if any.    IntelMobileString      m_sFilePath;                      // File location. Defaults to current dir.    unsigned int m_nMilliSecondsBeforeRenameAbort; // Time before the rename aborts in failure condition    unsigned int m_nMaxLogFileSizeKB;              // Size of logfile at which new one should be created    unsigned int m_nSecondsBetweenSizeChecks;      // Time between successive file size checks    HANDLE       m_hEventClose;                    // Event to signal when it's time to close the logfile    HANDLE       m_hEventOpen;                     // Event to signal when it's time to open the logfile    HANDLE       m_hProcessMutex;                  // Process Mutex, used to stop VLog when opening and closing the file    HANDLE       m_hMasterMutex;                   // Mutex used to determine who is the master process of the Log    bool         m_bThreadsActive;                 // Used to limit overhead to when threads are in use    void LogV( bool bStderr, DWORD dwLevel, const IntelMobileChar* pszMessage, va_list params );    bool OpenLogFile  ();    void CloseLogFile ();    bool RenameLogFile();    CLog( CLog& ) {}         // Prevent generation of accessible copy constructor.        const IntelMobileChar* GetLevelName( DWORD dwLevel );public:    CLog( );    CLog( const IntelMobileChar* pszLogfilename,           const IntelMobileChar* pszPrefix    = IntelMobileText(""),          const IntelMobileChar* pszMutexName = NULL,          DWORD          logLevel     = LOG_ALL,           bool           bStderr      = FALSE );    CLog( HKEY hKey,           const IntelMobileChar* pszSubkeyName,           const IntelMobileChar* pszLogfileName,          const IntelMobileChar* pszDefaultLogfileName  = IntelMobileText("Log.log"),           const IntelMobileChar* pszUselogfile          = NULL,          DWORD          dwUseLogfile           = 1,           const IntelMobileChar* pszMutexName           = NULL,          const IntelMobileChar* pszLogLevelValueName   = NULL,           DWORD          logLevel               = LOG_ALL,          bool           bStderr                = false );    virtual ~CLog();    bool RegisterLogfile( const IntelMobileChar* pszLogfilename,                           const IntelMobileChar* pszMutexName = NULL,                          DWORD          logLevel     = LOG_ALL,                           bool           bStderr      = FALSE );    bool           BackupLogFile    ();    DWORD          GetLogLevel      ()                          { return m_logLevel;        }    void           SetLogLevel      ( DWORD logLevel );    void           SetPrefix        ( const IntelMobileChar* psPrefix ) { m_sPrefix = psPrefix;     }    const IntelMobileChar* GetPrefix        ()                          { return m_sPrefix.c_str(); }    bool           GetPrintStderr   ()                          { return m_bStderr;         }    void           SetPrintStderr   ( bool  bStderr  )          { m_bStderr  = bStderr;     }    const IntelMobileChar* GetFileName      ()                          { return m_sLogFileName.c_str(); }    const IntelMobileChar* GetFilePath      ();    void           SetFilePath      ( const IntelMobileChar* psPath )   { m_sFilePath = psPath;        }    unsigned int   GetMaxLogFileSize()                          { return m_nMaxLogFileSizeKB;  }    void           SetMaxLogFileSize( unsigned int nSize )      { m_nMaxLogFileSizeKB = nSize; }    void operator()( const IntelMobileChar*  pszMessage, ... );    void operator()( const IntelMobileChar*  pszMessage, va_list params );    void operator()( DWORD logLevel, const IntelMobileChar* pszMessage, ... );    void operator()( DWORD logLevel, const IntelMobileChar* pszMessage, va_list params );    void operator()( bool  bStderr,  DWORD logLevel, const IntelMobileChar* pszMessage, ... );    void operator()( bool  bStderr,  DWORD logLevel, const IntelMobileChar* pszMessage, va_list params );    bool StartSizeMonitorThreads( unsigned int nLogFileSizeKB                 = 2048,                                   bool         bMaster                        = true,                                   unsigned int nSecondsBetweenSizeChecks      = 60,                                  unsigned int nMilliSecondsBeforeRenameAbort = 30000 );    // Don't call any of these functions below, they are for exclusive use by    // the threads which don't have access to the private members of the Class.    void LogMutexWaitThread ();    void LogEventWaitThread ();    void LogRegMonitorThread();};extern CLog& GetLog();#endif//==============================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -