Repository navigation
Description
New Feature / Enhancement Checklist
- Report security issues confidentially.
- Any contribution is under this license.
- Before posting search existing issues.
Current Limitation
Parse Server builds the log message for every Cloud Function call and every trigger run before the logger decides whether to write it. The success logs default to info, so with logLevel set to error or warn each message is built and then discarded.
- Cloud Functions: the success log serializes the parameters and the whole result with
JSON.stringify(FunctionsRouter.js). - Triggers:
logTriggerAfterHookandlogTriggerSuccessBeforeHookserialize the object and the trigger result (triggers.js). Their callers convert the input before the call, for example withUtils.safeToJSON(parseObject)or, forafterFind, withJSON.stringify(resultsAsJSON), so that part runs even when the level issilent.
The logger knows which levels are disabled, because LoggerController replaces their methods with no-ops (LoggerController.js), but by then the caller has already built the message.
Measured on Parse Server 9.11.1-alpha.2 with logLevel: 'error' (Node.js 22, Apple M4 Pro), the Cloud Function success log cost about 0.01 ms per call for a 3 KB result, 0.07 ms for 17 KB and 0.14 ms for 93 KB, which was up to 2% of the server CPU time of those requests. The trigger logs were not measured. The code is unchanged on the current alpha branch.
Feature / Enhancement Description
Build these messages only when their level is enabled.
The logger already supports this: LoggerController.log calls any argument that is a function (LoggerController.js), and logRequest and logResponse pass their message as a function, so it is only built when verbose is enabled (LoggerController.js). The Cloud Function and trigger logs could pass their message the same way, with the conversions at the trigger call sites moved into that function.
Example Use Case
- Parse Server runs with
logLevel: 'warn'to keep the log volume low in production. - A client calls a Cloud Function that returns a large result, or saves an object of a class that has a
beforeSaveorafterSavetrigger. - Parse Server skips the serialization for the log line, because the line would not be written.
Alternatives / Workarounds
Set the corresponding logLevels options to silent:
logLevels: {
cloudFunctionSuccess: 'silent',
triggerAfter: 'silent',
triggerBeforeSuccess: 'silent',
}This skips the serialization inside the log functions, but not the conversions at the trigger call sites. It also has to be kept in sync with logLevel by hand: the lines stay off when logLevel is later raised to info.
3rd Party References
Other loggers defer expensive log arguments in a similar way, for example lambda suppliers in Log4j 2 and isLevelEnabled in pino.
Activity
parse-github-assistant commentedon Nov 15, 2026
🚀 Thanks for opening this issue! We are excited about your ideas for improvement!
Mani7527 commentedon Nov 24, 2026
Hi! I'd like to work on this. I checked that it still applies on current
alpha: the Cloud Function success log still runsJSON.stringifyon the input and result inFunctionsRouter.js, and the trigger call sites still convert the object (Utils.safeToJSON,JSON.stringify(resultsAsJSON)forafterFind) before calling the log helpers.My plan:
LoggerController.logonly builds it when the level is enabled, the same waylogRequest/logResponsedologTriggerAfterHookandlogTriggerSuccessBeforeHook, moving the conversions at their call sites into that functionlogLevel: 'error'), and that the log output is unchanged when it is enabledI'll open a PR against
alphaonce the tests pass.