From 2d12f8a8ee537a5b6b98079b00b3095061de97da Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 8 Aug 2021 19:38:27 +0200 Subject: [PATCH] Mention that arguments are always evaluated, to curb enthusiasm at putting too much fancy stuff in a logger call ;). (Not actually an issue in our current codebase). --- doc/Hacking.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/Hacking.md b/doc/Hacking.md index 2dc060d66..e5288e93a 100644 --- a/doc/Hacking.md +++ b/doc/Hacking.md @@ -17,7 +17,12 @@ Anything printed by `logger.dbg` starts with `DEBUG`. 04/06/17-21:44:53 DEBUG foo ``` -## Bug hunting in kpv +In production code, remember that arguments are *always* evaluated in Lua, so, +don't inline complex computations in logger functions' arguments. +If you *really* have to, hide the whole thing behind a `dbg.is_on` branch, +like in [frontend/device/input.lua](https://github.com/koreader/koreader/blob/ba6fef4d7ba217ca558072f090849000e72ba142/frontend/device/input.lua#L1131-L1134). + +## Bug hunting in KPV (KOReader's predecessor) A real example of bug hunting in KPV's cache system: