(core) Fix issue with sandboxUtil where %s in message would get interpreted wrongly

Summary:
- Also converted sandboxUtil to typescript.
- The issue with %s manifested when a Python traceback contained "%s" in the
  string; in that case the object with log metadata (e.g. docId) would
  confusingly replace %s as if it were part of the message from Python.

Test Plan: Added a test case for the fix.

Reviewers: alexmojaki

Reviewed By: alexmojaki

Differential Revision: https://phab.getgrist.com/D3486
This commit is contained in:
Dmitry S
2022-06-14 02:49:59 -04:00
parent 983638a5c5
commit b57a211741
2 changed files with 17 additions and 26 deletions

View File

@@ -126,7 +126,7 @@ export function setTmpLogLevel(level: string, optCaptureFunc?: (level: string, m
* captures those at minLevel and higher. Returns a promise for the array of "level: message"
* strings. These may be tested using testUtils.assertMatchArray(). Callback may return a promise.
*/
export async function captureLog(minLevel: string, callback: any) {
export async function captureLog(minLevel: string, callback: () => void|Promise<void>): Promise<string[]> {
const messages: string[] = [];
const prevLogLevel = log.transports.file.level;
const name = _.uniqueId('CaptureLog');