命名空間:debug

  • 這個頁面中的內容
  • debug

debug

Debug()

輸出安全性規則語言的基本偵錯函式 物件、變數和陳述式結果 透過安全規則引擎進行評估debug 的輸出內容會寫入 Firestore-debug.log。

只能在「規則」中呼叫 debug 函式 限制條件

debug 函式區塊只會由以下安全性規則引擎執行: Firestore 模擬器,這是 Firebase Emulator 套件的一部分。偵錯 函式在實際工作環境中沒有作用。

偵錯記錄檔項目前面會加上一個識別規則的字串 記錄輸出的語言資料類型 (例如 string_valuemap_value)。

debug 的呼叫可採用巢狀結構。

目前 debug 功能不支援記錄概念 等級 (例如 INFO、WARN、ERROR)。

// firestore.rules
// Nested debug calls in the following match block....
match
/carts/{cartID} {
  allow create
: if request.auth != null && request.auth.uid == request.resource.data.ownerUID;
    allow read
, update, delete: if
      debug
(
        debug
(request.auth.uid) == debug(resource.data.ownerUID)
     
);
 
}
...

// firestore-debug.log
// ...produce logfile output like the following.
string_value
: "alice" // for debug(request.auth.uid)

string_value
: "alice" // for debug(resource.data.ownerUID)

bool_value
: true      // for the outermost enclosing debug() call
...

Firebase gives you the tools and infrastructure you need to build better mobile and web apps, improve app quality, and grow your business.

更新時間:Aug 21, 2024