rules. debug
namespace static
调试
使用“debug”
一个基本调试函数,可输出安全规则语言
对象、变量和语句结果。
是由安全规则引擎评估的debug
的输出会写入
firestore-debug.log。
debug
函数只能在规则内调用
条件。
debug
函数块仅由安全规则引擎在
Firestore 模拟器(Firebase Emulator Suite 的一部分)调试
对生产环境没有任何影响。
调试日志文件条目的前缀是用于标识规则的字符串
日志输出的语言数据类型(例如 string_value
、
map_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
...