主题
创建日志实例 - LogCreateInstance
函数简介
创建新的日志实例,用于实现多实例日志管理。
接口名称
LogCreateInstanceDLL调用
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)无需创建,始终存在。 |
| 路径 | 每个实例可以有独立的配置(路径、级别、格式等)。 |
| 适合需要分类管理日志的场景(按模块、按功能等) | 适合需要分类管理日志的场景(按模块、按功能等)。 |
