📄 rvfileloglistener.c
字号:
#if (0)
************************************************************************
Filename:
Description:
************************************************************************
Copyright (c) 2001 RADVision Inc.
************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision LTD.
No part of this publication may be reproduced in any form whatsoever
without written prior approval by RADVision LTD..
RADVision LTD. reserves the right to revise this publication and make
changes without obligation to notify any person of such revisions or
changes.
************************************************************************
************************************************************************
$Revision:$
$Date:$
$Author: S. Cipolli$
************************************************************************
#endif
#include "rvplatform.h"
#include "rvlog.h"
#include "rvfileloglistener.h"
#if (RV_LOGMASK != RV_LOGMASK_NONE)
static void rvFileLogListenerHandler(const RvLogRecord* rec, void* data) {
#if defined(RV_FILEIO_ANSI)
RvFileLogListener* l = (RvFileLogListener*)data;
char name[128];
if (!l->enabled)
return;
if (l->fp == NULL) {
sprintf(name, "%s%d.txt", l->prefix, l->toggle + 1);
l->fp = fopen(name, "w");
}
/* If we couldn't open the file then set flag so we don't keep trying */
if (l->fp == NULL) {
l->enabled = rvFalse;
return;
}
rvLogStdio(rec, l->fp);
l->count++;
if (l->count == l->entries) {
fclose(l->fp);
l->fp = NULL;
l->count = 0;
l->toggle = (l->toggle) ? 0 : 1;
}
#endif
}
/*$
{function:
{name: rvFileLogListenerConstruct}
{class: RvFileLogListener}
{include: rvfileloglistener.h}
{description:
{p: Construct a File Log Listener object.}
}
{proto: RvFileLogListener* rvFileLogListenerConstruct(RvFileLogListener* l, RvLogMask m, const char* prefix, size_t entries);}
{params:
{param: {n: l} {d: A pointer to the File Log Listener.}}
{param: {n: m} {d: The log mask specifying the Log Levels of the Log Records to processed.}}
{param: {n: prefix} {d: The file name prefix for the log files. The prefix can be up to 126 characters in length
and may contain a directory path.}}
{param: {n: entries} {d: The number of entries to log in each file}}
}
{returns: The RvLogListener object that represents this RvFileLogListener object.}
{see_also:
{n: RvLogListener}
}
}
$*/
RvFileLogListener* rvFileLogListenerConstruct(RvFileLogListener* l,
RvLogMask m, const char* prefix, size_t entries) {
l->fp = NULL;
l->count = 0;
l->toggle = 0;
l->enabled = rvTrue;
strcpy(l->prefix, prefix);
l->entries = entries;
rvLogListenerConstruct(&l->listener, m, rvFileLogListenerHandler, l);
return l;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -