在模擬器套件 UI 中查詢記錄

Firebase Local Emulator Suite 提供豐富的使用者介面,包括支援查看模擬器記錄。您可以使用本頁所述的查詢語法,在 Emulator Suite UI 中篩選記錄。

請注意以下有關這種語言及其語法的資訊:

  • 支援的操作:

    • 完全比對 (key=value)
    • 模糊文字搜尋 (search=value 或未鍵入文字)
    • 使用多個 key=value 運算式,並以空格或換行符號分隔 (例如 search=github search=com),即可建立邏輯 AND 組合。不支援 and 關鍵字。
  • 任何不含明確鍵的查詢都會視為單一 search 字詞,包括任何空格。

  • 只有明確 key=value 運算式中的值 (例如 search="github") 才支援引號。除非值包含空格或換行符號 (例如 search="hello world"),否則引號為選用。

以下列舉幾個使用記錄查詢語言查詢 Emulator Suite UI 的範例:

// Find info logs only.
level=info

// Find logs for the `sayHelloWorld` function.
metadata.emulator.name=functions
metadata.function.name=sayHelloWorld

// Find any log mentioning `"hello world"`.
hello world  // turns into `search="hello world"` internally

// Return any Hosting `POST` requests.
metadata.emulator.name=hosting
search=POST

關鍵字

Emulator Suite UI 記錄查詢語言支援下列關鍵字:

level

記錄層級。

可能的值為 warn、info、error。

模糊搜尋中要比對的文字。

例如,search=abc 會傳回含有 "abc" 文字的記錄。

使用 search 關鍵字合併多個模糊搜尋 (例如 search=github search=com),或將模糊搜尋與其他關鍵字搜尋合併 (例如 metadata.emulator.name=hosting search=POST)。

metadata

記錄項目的中繼資料,例如模擬器或函式名稱。

metadata.emulator.name

產生記錄的模擬器。

可能的值為 firestore、functions、database、pubsub、hosting、storage。

metadata.function.name

應用程式程式碼中定義的函式名稱。

user

您可以在 user 下方查詢從應用程式程式碼記錄的任何 JSON 資料。

例如:

console.log(JSON.stringify({hello: "world"}))

您可以使用 user.hello="world" (或 user.hello=world) 查詢記錄輸出內容。