Skip to content

Commit 0529d97

Browse files
committed
Add some testing for --log-level, --log and --log-format options
1 parent cfb6422 commit 0529d97

File tree

6 files changed

+408
-9
lines changed

6 files changed

+408
-9
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"name": "Run Quarto test",
3737
"request": "launch",
3838
"type": "node",
39-
"program": "smoke/smoke-all.test.ts", // test script here
39+
"program": "smoke/logging/log-level-direct.test.ts", // test script here
4040
"args": [], // args to the script here, like in command line smoke/smoke-all.test.t -- .\docs\smoke-all\2023\01\19\2107.qmd
4141
"cwd": "${workspaceFolder}/tests",
4242
"runtimeExecutable": "${workspaceFolder}/package/dist/bin/tools/deno",

src/core/log.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ import { pandocBinaryPath } from "./resources.ts";
2424
import { Block, pandoc } from "./pandoc/json.ts";
2525

2626
export type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR" | "CRITICAL";
27+
export type LogFormat = "plain" | "json-stream";
2728

2829
export interface LogOptions {
2930
log?: string;
3031
level?: string;
31-
format?: "plain" | "json-stream";
32+
format?: LogFormat;
3233
quiet?: boolean;
3334
newline?: true;
3435
}
@@ -265,7 +266,7 @@ export class LogFileHandler extends FileHandler {
265266
interface LogFileHandlerOptions {
266267
filename: string;
267268
mode?: "a" | "w" | "x";
268-
format?: "plain" | "json-stream";
269+
format?: LogFormat;
269270
}
270271

271272
export function flushLoggers(handlers: Record<string, BaseHandler>) {

tests/docs/logging/error-filter.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- error-filter.lua
2+
-- This filter purposely generates an error for testing error logging
3+
4+
function Pandoc(doc)
5+
-- Generate an error
6+
internal_error("This is a deliberate error from error-filter.lua for testing purposes")
7+
return doc
8+
end

tests/docs/logging/lua-error.qmd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: "Lua Error Test"
3+
format: html
4+
filters:
5+
- error-filter.lua
6+
---
7+
8+
## Test Content
9+
10+
This document will trigger a Lua filter error because the error-filter.lua purposely generates an error.

0 commit comments

Comments
 (0)