Emulator Suite UI でログをクエリする

Firebase Local Emulator Suite には、エミュレータ ログの表示をサポートする充実したユーザー インターフェースが用意されています。このページで説明するクエリ構文を使用して、Emulator Suite UI でログをフィルタできます。

この言語とその構文については、次の点に注意してください。

  • サポートされているオペレーション:

    • 完全一致の比較(key=value)
    • ファジー テキスト検索(search=value またはキーなしテキスト)
    • スペースまたは改行で区切られた複数の key=value 式を使用した論理 AND の組み合わせ(例: search=github search=com)。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

アプリコードからロギングされた JSON データは、user でクエリできます。

例:

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

ログ出力は user.hello="world"(または user.hello=world)でクエリできます。