Skip to content

写入TRACE日志 - LogTrace

函数简介

写入 TRACE 级别日志到默认日志实例。

接口名称

LogTrace

DLL调用

c
int32_t LogTrace(int64_t instance, const char* message);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
message字符串日志消息。

示例

推荐联动顺序:

LogSetLevel(0, 0) → LogSetTarget(0, 1|2) → OpenConsole(0)
        → LogTrace("...") → LogFlush(0)

TRACE=0,最细粒度;便于跟踪函数进出LogSetTarget(0, 1|2) = FILE|CONSOLE。

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;

// 默认实例 loggerHandle=0;LogTrace 只接收 message,无句柄参数
ola.LogSetLevel(0, 0);          // TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget(0, 1 | 2);    // FILE | CONSOLE
ola.OpenConsole(0);            // 打开插件进程控制台

ola.LogTrace("enter MatchImage, region=(0,0,800,600)");
ola.LogFlush(0);
csharp
using OLAPlug;

var ola = new OLAPlugServer();

ola.LogSetLevel(0, 0);       // TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget(0, 1 | 2); // FILE | CONSOLE
ola.OpenConsole(0);

ola.LogTrace("enter MatchImage, region=(0,0,800,600)");
ola.LogFlush(0);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()

ola.LogSetLevel(0, 0)       # TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget(0, 1 | 2)  # FILE | CONSOLE
ola.OpenConsole(0)

ola.LogTrace("enter MatchImage, region=(0,0,800,600)")
ola.LogFlush(0)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();

ola.LogSetLevel(0, 0);       // TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget(0, 1 | 2); // FILE | CONSOLE
ola.OpenConsole(0);

ola.LogTrace("enter MatchImage, region=(0,0,800,600)");
ola.LogFlush(0);
go
import "github.com/ola/olaplug/olaplug"

ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()

ola.LogSetLevel(0, 0)       // TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget(0, 1|2)   // FILE | CONSOLE
ola.OpenConsole(0)

ola.LogTrace("enter MatchImage, region=(0,0,800,600)")
ola.LogFlush(0)
rust
use olaplug::OLAPlugServer;

let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();

ola.log_set_level(0, 0);       // TRACE=0,最细粒度;便于跟踪函数进出
ola.log_set_target(0, 1 | 2); // FILE | CONSOLE
ola.open_console(0);

ola.log_trace("enter MatchImage, region=(0,0,800,600)");
ola.log_flush(0);
cpp
var ola = com("OlaPlug.OlaSoft")

ola.LogSetLevel(0, 0)       // TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget(0, 1 | 2) // FILE | CONSOLE
ola.OpenConsole(0)

ola.LogTrace("enter MatchImage, region=(0,0,800,600)")
ola.LogFlush(0)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")

ola.LogSetLevel 0, 0       ' TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget 0, 3     ' 1|2 = FILE|CONSOLE
ola.OpenConsole 0

ola.LogTrace "enter MatchImage, region=(0,0,800,600)"
ola.LogFlush 0
text
.局部变量 ola, OLAPlug

ola.Create ()
ola.LogSetLevel (0, 0)       ' TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget (0, 位或 (1, 2))  ' FILE | CONSOLE
ola.OpenConsole (0)

ola.LogTrace (“enter MatchImage, region=(0,0,800,600)”)
ola.LogFlush (0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();

ola.LogSetLevel(0, 0);       // TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget(0, 1 | 2); // FILE | CONSOLE
ola.OpenConsole(0);

ola.LogTrace("enter MatchImage, region=(0,0,800,600)");
ola.LogFlush(0);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer

ola.LogSetLevel(0, 0)       ' TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget(0, 1 位或 2)  ' FILE | CONSOLE
ola.OpenConsole(0)

ola.LogTrace("enter MatchImage, region=(0,0,800,600)")
ola.LogFlush(0)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;

ola.LogSetLevel(0, 0);       // TRACE=0,最细粒度;便于跟踪函数进出
ola.LogSetTarget(0, 1 | 2); // FILE | CONSOLE
ola.OpenConsole(0);

ola.LogTrace("enter MatchImage, region=(0,0,800,600)");
ola.LogFlush(0);

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();

// Native: LogTrace(instance, message) — 无 loggerHandle
LogSetLevel(instance, 0, 0);
LogSetTarget(instance, 0, 1 | 2); // FILE | CONSOLE
OpenConsole(instance, 0);

LogTrace(instance, "enter MatchImage, region=(0,0,800,600)");
LogFlush(instance, 0);
csharp
using System.Runtime.InteropServices;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int LogSetLevel(long ola, long loggerHandle, int level);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int LogSetTarget(long ola, long loggerHandle, int targetFlags);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int OpenConsole(long ola, int type);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int LogTrace(long ola, string message);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int LogFlush(long ola, long loggerHandle);

long instance = CreateCOLAPlugInterFace();
LogSetLevel(instance, 0, 0);
LogSetTarget(instance, 0, 1 | 2);
OpenConsole(instance, 0);
LogTrace(instance, "enter MatchImage, region=(0,0,800,600)");
LogFlush(instance, 0);
python
from ctypes import CDLL, c_int, c_int64, c_char_p

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.LogSetLevel.argtypes = [c_int64, c_int64, c_int]
ola.LogSetTarget.argtypes = [c_int64, c_int64, c_int]
ola.OpenConsole.argtypes = [c_int64, c_int]
ola.LogTrace.argtypes = [c_int64, c_char_p]
ola.LogFlush.argtypes = [c_int64, c_int64]

instance = ola.CreateCOLAPlugInterFace()
ola.LogSetLevel(instance, 0, 0)
ola.LogSetTarget(instance, 0, 1 | 2)
ola.OpenConsole(instance, 0)
ola.LogTrace(instance, "enter MatchImage, region=(0,0,800,600)".encode("utf-8"))
ola.LogFlush(instance, 0)

返回值

返回值说明
1成功。
0失败。

注意事项

项目说明
TRACE 是最低级别的日志TRACE 是最低级别的日志,用于详细的程序执行跟踪。
OLA_LOG_LEVEL_TRACE只有当日志级别设置为 OLA_LOG_LEVEL_TRACE (0) 时才会输出。
在开发和调试阶段使用建议在开发和调试阶段使用,生产环境建议使用更高级别。
如果需要指定日志实例如果需要指定日志实例,请使用 LogTraceEx
如果日志系统未初始化如果日志系统未初始化,第一次调用时会自动初始化。