跳到內容
Tauri

@tauri-apps/plugin-log

介面

LogOptions

屬性

屬性類型定義於
file?stringSource: 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?numberSource: 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>

為日誌附加一個監聽器,並為每個日誌條目呼叫傳入的函式。

參數

參數類型描述
fnLoggerFn

回傳

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 層級記錄訊息。

參數

參數類型描述
messagestring# 範例 import { debug } from '@tauri-apps/plugin-log'; const pos = { x: 3.234, y: -1.223 }; debug(New position: 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 層級記錄訊息。

參數

參數類型描述
messagestring# 範例 import { error } from '@tauri-apps/plugin-log'; const err_info = "No connection"; const port = 22; error(Error: ${err_info} on port ${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 層級記錄訊息。

參數

參數類型描述
messagestring# 範例 import { info } from '@tauri-apps/plugin-log'; const conn_info = { port: 40, speed: 3.20 }; info(Connected to port {conn_info.port} at {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 層級記錄訊息。

參數

參數類型描述
messagestring# 範例 import { trace } from '@tauri-apps/plugin-log'; let pos = { x: 3.234, y: -1.223 }; trace(Position is: 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 層級記錄訊息。

參數

參數類型描述
messagestring# 範例 import { warn } from '@tauri-apps/plugin-log'; const warn_description = "Invalid Input"; warn(Warning! {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 Contributors. CC-BY / MIT