命名空間:調試

偵錯

偵錯()

基本偵錯功能,在安全規則引擎評估安全規則語言物件、變數和語句結果時列印它們。 debug的輸出寫入 firestore-debug.log。

debug函數只能在規則條件內呼叫。

debug功能塊僅由 Firestore 模擬器(Firebase 模擬器套件的一部分)中的安全規則引擎執行。調試功能對生產沒有影響。

在偵錯日誌檔案條目前面新增了一個字串,該字串標識日誌輸出的規則語言資料類型(例如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
...