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

📄 rvlog.h

📁 基于h323协议的软phone
💻 H
📖 第 1 页 / 共 2 页
字号:
/***********************************************************************
Filename   : rvlog.h
Description: log handling
************************************************************************
        Copyright (c) 2001 RADVISION Inc. and RADVISION Ltd.
************************************************************************
NOTICE:
This document contains information that is confidential and proprietary
to RADVISION Inc. and RADVISION Ltd.. No part of this document may be
reproduced in any form whatsoever without written prior approval by
RADVISION Inc. or RADVISION Ltd..

RADVISION Inc. and RADVISION Ltd. reserve the right to revise this
publication and make changes without obligation to notify any person of
such revisions or changes.
***********************************************************************/

#ifndef RV_LOG_H
#define RV_LOG_H

#include "rvlock.h"
#include "rvthread.h"
#include "rvccore.h"
#include "rvcbase.h"


#if defined(__cplusplus)
extern "C" {
#endif


/* Use these macro definitions when constructing a log source. */
#define RV_LOG_LIBCODE_ANY 0
#define RV_LOG_LIBCODE_CUTILS 1
#define RV_LOG_LIBCODE_CCORE 2
#define RV_LOG_LIBCODE_CBASE 3
#define RV_LOG_LIBCODE_H323 4
#define RV_LOG_LIBCODE_ASN1 5
#define RV_LOG_LIBCODE_SIP 6
#define RV_LOG_LIBCODE_H245 7
#define RV_LOG_LIBCODE_3G324M 8

/* Module specific error codes (-512..-1023). See rverror.h dor more details */
#define RV_LOG_ERROR_RECURSION -512 /* Logging an error might cause an endless recursion */
#define RV_LOG_ERROR_ALREADY_REGISTERED -513 /* Listener is already registered to this log object */



/************************************************************************
 * Severity of a LOG message
 * EXCEP    - Possible bug in the code
 * ERROR    - Cannot continue with current operation
 * WARNING  - Warning about a possible problem
 * INFO     - Debug information
 * DEBUG    - Detailed deubg information
 * ENTER    - Entry to a function
 * LEAVE    - Exit from a function
 ************************************************************************/
#define RV_LOGLEVEL_EXCEP       RvUint8Const(0x01)
#define RV_LOGLEVEL_ERROR       RvUint8Const(0x02)
#define RV_LOGLEVEL_WARNING     RvUint8Const(0x04)
#define RV_LOGLEVEL_INFO        RvUint8Const(0x08)
#define RV_LOGLEVEL_DEBUG       RvUint8Const(0x10)
#define RV_LOGLEVEL_ENTER       RvUint8Const(0x20)
#define RV_LOGLEVEL_LEAVE       RvUint8Const(0x40)

#define RV_LOGLEVEL_ALL         RvUint8Const(0xff)
#define RV_LOGLEVEL_NONE        RvUint8Const(0x00)



/************************************************************************
 * RV_LOGMASK_COMPILEMASK
 * Determines the compile-time log level features available. If this is
 * defined by the user, it won't be redefined here.
 * todo: move to ccoreconfig or cbaseconfig
 ************************************************************************/
#if !defined(RV_LOGMASK_COMPILEMASK)
#define RV_LOGMASK_COMPILEMASK  RV_LOGLEVEL_ALL
#endif


/************************************************************************
 * RV_LOGMASK_DEFAULT
 * Determines the default run-time log level.
 * By default the level is RV_LOGMASK_COMPILEMASK
 ************************************************************************/
#if !defined(RV_LOGMASK_DEFAULT)
#define RV_LOGMASK_DEFAULT   (RV_LOGMASK_COMPILEMASK)
#endif



/* Log manager object */
typedef struct RvLogMgrInternal RvLogMgr;


/* Source of log messages */
typedef struct RvLogSourceInternal* RvLogSource;


/* Type of message being logged */
typedef RvUint8 RvLogMessageType;


/* Log information associated with a log message. This struct is given
   to the printing function on each log message. */
typedef struct RvLogRecordInternal RvLogRecord;


/********************************************************************************************
 * RvLogPrintCb
 *
 * purpose : Callback that is executed whenever a message has to be logged somewhere
 * input   : logRecord  - Information related with the logged message
 *           userData   - User related data, given when the printing function was set
 * output  : None
 * return  : None
 * remarks : The log record holds a pointer to the message to log. This message has
 *           a set amount of bytes before it allocated but unused to allow better
 *           formatting of messages. That amount is RV_LOG_RESERVED_BYTES.
 ********************************************************************************************/
typedef void
    (RVCALLCONV* RvLogPrintCb)(
        IN RvLogRecord* logRecord,
        IN void*        userData);


/* Maximum number of listeners for a logging object */
#define RV_LOG_MAX_LISTENERS RvInt32Const(10)


/* Amount of reserved bytes before message when inside the log callback */
#define RV_LOG_RESERVED_BYTES RvInt32Const(128)

/* Maximum size of each message, without the reserved bytes */
#define RV_LOG_MESSAGE_SIZE RvInt32Const(1024)


#include "rvloginternal.h"




/* Prototypes and macros */

RvStatus RvLogInit(void);
RvStatus RvLogEnd(void);


/********************************************************************************************
 * RvLogGet
 *
 * purpose : Get the pointer to the global log manager
 * input   : None
 * output  : None
 * return  : Pointer to global log manager
 ********************************************************************************************/
RVCOREAPI
RvLogMgr* RVCALLCONV RvLogGet(void);


/********************************************************************************************
 * RvLogConstruct
 *
 * purpose : Create a log object. Only a single such object is used by the core and the
 *           stacks on top of it.
 * input   : logMgr - Log manager to construct
 * output  : None
 * return  : RV_OK on success, other on failure
 ********************************************************************************************/
RVCOREAPI
RvStatus RVCALLCONV RvLogConstruct(IN RvLogMgr* logMgr);


/********************************************************************************************
 * RvLogDestruct
 *
 * purpose : Kill a log object
 * input   : logMgr - Log manager to destruct
 * output  : None
 * return  : RV_OK on success, other on failure
 ********************************************************************************************/
RVCOREAPI
RvStatus RVCALLCONV RvLogDestruct(IN RvLogMgr* logMgr);


/********************************************************************************************
 * RvLogRegisterListener
 *
 * purpose : Set a listener function to the log. Multiple listeners can be set on each log
 *           object. The listener is used to actually log the messages.
 * input   : logMgr     - Log manager to use
 *           listener   - Listener function, called on each message
 *           userData   - User data set as a parameter of the listener function
 * output  : None
 * return  : RV_OK on success, other on failure
 ********************************************************************************************/
RVCOREAPI
RvStatus RVCALLCONV RvLogRegisterListener(
    IN RvLogMgr*    logMgr,
    IN RvLogPrintCb listener,
    IN void*        userData);


/********************************************************************************************
 * RvLogUnregisterListener
 *
 * purpose : Unset a listener function from the log.
 * input   : logMgr     - Log manager to use
 *           listener   - Listener function, called on each message
 * output  : None
 * return  : RV_OK on success, other on failure
 ********************************************************************************************/
RVCOREAPI
RvStatus RVCALLCONV RvLogUnregisterListener(
    IN RvLogMgr*    logMgr,
    IN RvLogPrintCb listener);


/********************************************************************************************
 * RvLogSourceConstruct
 *
 * purpose : Create a new source of messages in a log manager
 * input   : logMgr     - Log manager
 *           source     - Source of messages to create
 *           libraryCode- Library code number this source is in (RV_LOG_LIBCODE_CBASE for example)
 *                        Constructing a log source with RV_LOG_LIBCODE_ANY allows a logger to
 *                        initialize the logging facilities before anyone actually registers
 *                        here and "catch" their registration.
 *           name       - Name of the source
 *           description- Description of the source
 * output  : None
 * return  : RV_OK on success, other on failure
 ********************************************************************************************/
RVCOREAPI
RvStatus RVCALLCONV RvLogSourceConstruct(
    IN RvLogMgr*        logMgr,
    IN RvLogSource*     source,
    IN RvUint32         libraryCode,
    IN const RvChar*    name,
    IN const RvChar*    description);


/********************************************************************************************
 * RvLogSourceDestruct
 *
 * purpose : Delete a source of messages from a log manager
 * input   : logMgr     - Log manager
 *           source     - Source of messages to delete
 * output  : None
 * return  : RV_OK on success, other on failure
 ********************************************************************************************/
RVCOREAPI
RvStatus RVCALLCONV RvLogSourceDestruct(
    IN RvLogMgr*        logMgr,
    IN RvLogSource*     source);


⌨️ 快捷键说明

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