Skip to content

创建日志实例 - LogCreateInstance

函数简介

创建新的日志实例,用于实现多实例日志管理。

接口名称

LogCreateInstance

DLL调用

c
int64_t LogCreateInstance(int64_t instance, const char* instanceName);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
instanceName字符串实例名称(用于标识,如 "NetworkLogger")。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long log = ola.LogCreateInstance();
csharp
using OLAPlug;

var ola = new OLAPlugServer();
long log = ola.LogCreateInstance();
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
log = ola.LogCreateInstance()
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
long log = ola.LogCreateInstance();
cpp
var ola = com("OlaPlug.OlaSoft")
var log = ola.LogCreateInstance()
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
log = ola.LogCreateInstance()
text
.局部变量 ola, OLAPlug
ola.创建 ()
log = ola.LogCreateInstance()
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var log = ola.LogCreateInstance();
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 log = ola.LogCreateInstance()
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long log = ola.LogCreateInstance();

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long log = LogCreateInstance(instance);
csharp
long instance = CreateCOLAPlugInterFace();
long log = LogCreateInstance(instance);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
log = LogCreateInstance(instance)

返回值

返回值说明
(返回值)日志实例句柄(长整数型),失败返回 0。

注意事项

项目说明
新创建的实例使用默认配置新创建的实例使用默认配置。
实例句柄必须通过 `LogDestroyInst实例句柄必须通过 LogDestroyInstance 释放。
实例(句柄 = 0)无需创建默认实例(句柄 = 0)无需创建,始终存在。
路径每个实例可以有独立的配置(路径、级别、格式等)。
适合需要分类管理日志的场景(按模块、按功能等)适合需要分类管理日志的场景(按模块、按功能等)。