@tauri-apps/plugin-log
接口
LogOptions
属性
属性 | 类型 | 定义在 |
---|---|---|
file? | string | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L9 |
keyValues? | Record <string , undefined | string > | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L11 |
line? | number | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L10 |
函数
attachConsole()
function attachConsole(): Promise<UnlistenFn>
附加一个监听器,将传入的日志条目写入控制台。
返回值
Promise
<UnlistenFn
>
用于取消监听器的函数。
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L277
attachLogger()
function attachLogger(fn): Promise<UnlistenFn>
附加日志监听器,并为每个日志条目调用传递的函数。
参数
参数 | 类型 | 描述 |
---|---|---|
fn | LoggerFn |
返回值
Promise
<UnlistenFn
>
用于取消监听器的函数。
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L256
debug()
function debug(message, options?): Promise<void>
在 debug 级别记录消息。
参数
参数 | 类型 | 描述 |
---|---|---|
message | string | # 示例 import { debug } from '@tauri-apps/plugin-log'; const pos = { x: 3.234, y: -1.223 }; debug( 新位置:x: {pos.x}, y: {pos.y}); |
options ? | LogOptions | - |
返回值
Promise
<void
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L214
error()
function error(message, options?): Promise<void>
在 error 级别记录消息。
参数
参数 | 类型 | 描述 |
---|---|---|
message | string | # 示例 import { error } from '@tauri-apps/plugin-log'; const err_info = "No connection"; const port = 22; error( 错误:${err_info} 在端口 ${port} 上); |
options ? | LogOptions | - |
返回值
Promise
<void
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L148
info()
function info(message, options?): Promise<void>
在 info 级别记录消息。
参数
参数 | 类型 | 描述 |
---|---|---|
message | string | # 示例 import { info } from '@tauri-apps/plugin-log'; const conn_info = { port: 40, speed: 3.20 }; info( 连接到端口 {conn_info.port},速度为 {conn_info.speed} Mb/s); |
options ? | LogOptions | - |
返回值
Promise
<void
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L192
trace()
function trace(message, options?): Promise<void>
在 trace 级别记录消息。
参数
参数 | 类型 | 描述 |
---|---|---|
message | string | # 示例 import { trace } from '@tauri-apps/plugin-log'; let pos = { x: 3.234, y: -1.223 }; trace( 位置是:x: {pos.x}, y: {pos.y}); |
options ? | LogOptions | - |
返回值
Promise
<void
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L236
warn()
function warn(message, options?): Promise<void>
在 warn 级别记录消息。
参数
参数 | 类型 | 描述 |
---|---|---|
message | string | # 示例 import { warn } from '@tauri-apps/plugin-log'; const warn_description = "Invalid Input"; warn( 警告!{warn_description}!); |
options ? | LogOptions | - |
返回值
Promise
<void
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L170
© 2025 Tauri 贡献者。CC-BY / MIT