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

📄 kwqlogging.h

📁 手机浏览器源码程序,功能强大
💻 H
字号:
/*
 * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
 * Portions Copyright (c) 2005 Nokia Corporation, Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
 */

// ========== LOGGING MACROS ===============================

#ifndef KWQLOGGING_H
#define KWQLOGGING_H

#include "KWQAssertions.h"

#ifndef LOG_CHANNEL_PREFIX
#define LOG_CHANNEL_PREFIX KWQLog
#endif

extern KWQLogChannel KWQLogNotYetImplemented;

extern KWQLogChannel KWQLogFrames;
extern KWQLogChannel KWQLogLoading;
extern KWQLogChannel KWQLogPopupBlocking;
extern KWQLogChannel KWQLogEvents;
extern KWQLogChannel KWQLogEditing;

#include <e32std.h>
#include <e32def.h>
#include <flogger.h>
#include <f32file.h>

#define USE_LOGGER

#ifdef USE_LOGGER

/*  logging macros usage:

// replace WC with your own TLA (Three Letter Acronyme).

// set logging on in mmp file...
MACRO USE_LOGGER
#ifdef WINS
MACRO USE_RDEBUG
#endif


void CTestAppUi::ConstructL()
{
    // creates log directory and log file on app startup.
    // prints starting banner...
    WCLOGGER_CREATE(iFs);

    // entering to function...
    WCLOGGER_ENTERFN("ConstructL()");

    TInt number = 42;
    TFileName file;
    file = "something" ....

    // print variable number of parameters...
    // Note: use _L macro for format string!
    WCLOGGER_WRITEF(_L("WC: number = %d, file = %S"), number, &file);

    // print just a string (no _L macro here!)
    WCLOGGER_WRITE("Hello world!");

    // leave from function...
    WCLOGGER_LEAVEFN("ConstructL()");
}

CTestAppUi::~CTestAppUi()
{
    // print app exit banner when application exits.
    WCLOGGER_DELETE;
}

*/

#ifdef USE_RDEBUG

_LIT(KWCLogBanner,             "WC");
_LIT(KWCLogEnterFn,            "WC: >> %S");
_LIT(KWCLogLeaveFn,            "WC: << %S");
_LIT(KWCLogWrite,              "WC: %S");
_LIT(KWCLogTag,                "WC: ");
_LIT(KWCLogExit,               "WC: Application exit");
_LIT(KWCLogTimeFormatString,   "%H:%T:%S:%*C2");

#define WCLOGGER_CREATE(a)          {RDebug::Print(KWCLogBanner);}
#define WCLOGGER_DELETE             {RDebug::Print(KWCLogExit);}
#define WCLOGGER_ENTERFN(a)         {_LIT(temp, a); RDebug::Print(KWCLogEnterFn, &temp);}
#define WCLOGGER_LEAVEFN(a)         {_LIT(temp, a); RDebug::Print(KWCLogLeaveFn, &temp);}
#define WCLOGGER_WRITE(a)           {_LIT(temp, a); RDebug::Print(KWCLogWrite, &temp);}
#define WCLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KWCLogTimeFormatString ); buffer.Insert(0, temp); buffer.Insert(0, KWCLogTag); RDebug::Print(buffer); }
#define WCLOGGER_WRITEF             RDebug::Print

#else

_LIT( KWCLogDir,               "Browser");
_LIT( KWCLogFile,              "WebCore.log");
_LIT8(KWCLogBanner,            "WC");
_LIT8(KWCLogEnterFn,           "WC: >> %S");
_LIT8(KWCLogLeaveFn,           "WC: << %S");
_LIT8(KWCLogExit,              "WC: Application exit");
_LIT( KWCLogTimeFormatString,  "%H:%T:%S:%*C2");

#define WCLOGGER_CREATE(a)          {FCreate(a);}
#define WCLOGGER_DELETE             {RFileLogger::Write(KWCLogDir, KWCLogFile, EFileLoggingModeAppend, KWCLogExit);}
#define WCLOGGER_ENTERFN(a)         {_LIT8(temp, a); RFileLogger::WriteFormat(KWCLogDir, KWCLogFile, EFileLoggingModeAppend, KWCLogEnterFn, &temp);}
#define WCLOGGER_LEAVEFN(a)         {_LIT8(temp, a); RFileLogger::WriteFormat(KWCLogDir, KWCLogFile, EFileLoggingModeAppend, KWCLogLeaveFn, &temp);}
#define WCLOGGER_WRITE(a)           {_LIT(temp, a); RFileLogger::Write(KWCLogDir, KWCLogFile, EFileLoggingModeAppend, temp);}
#define WCLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KWCLogTimeFormatString ); buffer.Insert(0, temp); RFileLogger::Write(KWCLogDir, KWCLogFile, EFileLoggingModeAppend, buffer); }
#define WCLOGGER_WRITEF             FPrint

inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
{
    VA_LIST list;
    VA_START(list,aFmt);
    RFileLogger::WriteFormat(KWCLogDir, KWCLogFile, EFileLoggingModeAppend, aFmt, list);
}

inline void FPrint(const TDesC& aDes)
{
    RFileLogger::WriteFormat(KWCLogDir, KWCLogFile, EFileLoggingModeAppend, aDes);
}

inline void FHex(const TUint8* aPtr, TInt aLen)
{
    RFileLogger::HexDump(KWCLogDir, KWCLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
}

inline void FHex(const TDesC8& aDes)
{
    FHex(aDes.Ptr(), aDes.Length());
}

inline void FCreate(RFs& aFs)
{
	// delete the log file
    TFileName path(_L("c:\\logs\\"));
    path.Append(KWCLogDir);
    path.Append(_L("\\"));
    aFs.MkDirAll(path);
    path.Append( KWCLogFile );

	// clear the existing log file
	aFs.Delete( path );

    RFileLogger::WriteFormat(KWCLogDir, KWCLogFile, EFileLoggingModeOverwrite, KWCLogBanner);
}

#endif // USE_RDEBUG

#else // USE_LOGGER

// dummy inline FPrint for WCLOGGER_WRITEF macro.
inline TInt FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { return 0; }

#define WCLOGGER_CREATE(a)
#define WCLOGGER_DELETE
#define WCLOGGER_ENTERFN(a)
#define WCLOGGER_LEAVEFN(a)
#define WCLOGGER_WRITE(a)
// if USE_LOGGER not defined this call to FPrint gets optimized away.
#define WCLOGGER_WRITEF 1 ? 0 : FPrint
#define WCLOGGER_WRITE_TIMESTAMP(a)

#endif // USE_LOGGER

#endif // WCLOGGING_H

⌨️ 快捷键说明

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