A basic debug function that prints Security Rules language
objects, variables and statement results as they are being
evaluated by the Security Rules engine. The outputs of debug are written to
firestore-debug.log.
The debug function can only be called inside Rules
conditions.
debug function blocks are only executed by the Security Rules engine in
the Firestore emulator, part of the Firebase Emulator Suite. The debug
function has no effect in production.
Debug logfile entries are prepended by a string identifying the Rules
language data type of the log output (for example, string_value,
map_value).
Calls to debug can be nested.
Currently, the debug feature does not support the concept of logging
levels (for example, INFO, WARN, ERROR).
// firestore.rules// Nested debug calls in the following match block....match/carts/{cartID}{allowcreate:ifrequest.auth!=null&&request.auth.uid==request.resource.data.ownerUID;allowread,update,delete:ifdebug(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...
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-06-10 UTC."],[],[],null,["# Namespace: debug\n\n[rules](/docs/reference/rules/rules).debug\n==========================================\n\nnamespace static\n\ndebug\n-----\n\ndebug()\n\nA basic debug function that prints Security Rules language\nobjects, variables and statement results as they are being\nevaluated by the Security Rules engine. The outputs of `debug` are written to\nfirestore-debug.log.\n\nThe `debug` function can only be called inside Rules\n[conditions](/docs/rules/rules-language#building_conditions).\n\n`debug` function blocks are only executed by the Security Rules engine in\nthe Firestore emulator, part of the Firebase Emulator Suite. The debug\nfunction has no effect in production.\n\nDebug logfile entries are prepended by a string identifying the Rules\nlanguage data type of the log output (for example, `string_value`,\n`map_value`).\n\nCalls to `debug` can be nested.\n\nCurrently, the `debug` feature does not support the concept of logging\nlevels (for example, INFO, WARN, ERROR). \n\n```scilab\n// firestore.rules\n// Nested debug calls in the following match block....\nmatch /carts/{cartID} {\n allow create: if request.auth != null && request.auth.uid == request.resource.data.ownerUID;\n allow read, update, delete: if\n debug(\n debug(request.auth.uid) == debug(resource.data.ownerUID)\n );\n }\n...\n\n// firestore-debug.log\n// ...produce logfile output like the following.\nstring_value: \"alice\" // for debug(request.auth.uid)\n\nstring_value: \"alice\" // for debug(resource.data.ownerUID)\n\nbool_value: true // for the outermost enclosing debug() call\n...\n```"]]