Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"name": "Run Quarto test",
"request": "launch",
"type": "node",
"program": "smoke/smoke-all.test.ts", // test script here
"program": "smoke/logging/log-level-direct.test.ts", // test script here
"args": [], // args to the script here, like in command line smoke/smoke-all.test.t -- .\docs\smoke-all\2023\01\19\2107.qmd
"cwd": "${workspaceFolder}/tests",
"runtimeExecutable": "${workspaceFolder}/package/dist/bin/tools/deno",
Expand Down
11 changes: 7 additions & 4 deletions src/core/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import { execProcess } from "./process.ts";
import { pandocBinaryPath } from "./resources.ts";
import { Block, pandoc } from "./pandoc/json.ts";

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

export interface LogOptions {
log?: string;
level?: string;
format?: "plain" | "json-stream";
format?: LogFormat;
quiet?: boolean;
newline?: true;
}
Expand All @@ -55,7 +56,7 @@ export function appendLogOptions(cmd: Command<any>): Command<any> {
},
).option(
"--log-level <level>",
"Log level (info, warning, error, critical)",
"Log level (debug, info, warning, error, critical)",
{
global: true,
},
Expand Down Expand Up @@ -265,7 +266,7 @@ export class LogFileHandler extends FileHandler {
interface LogFileHandlerOptions {
filename: string;
mode?: "a" | "w" | "x";
format?: "plain" | "json-stream";
format?: LogFormat;
}

export function flushLoggers(handlers: Record<string, BaseHandler>) {
Expand Down Expand Up @@ -460,7 +461,9 @@ const levelMap: Record<
debug: "DEBUG",
info: "INFO",
warning: "WARN",
warn: "WARN",
error: "ERROR",
critical: "CRITICAL",
};

export async function logPandocJson(
Expand Down
8 changes: 8 additions & 0 deletions tests/docs/logging/error-filter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- error-filter.lua
-- This filter purposely generates an error for testing error logging

function Pandoc(doc)
-- Generate an error
internal_error("This is a deliberate error from error-filter.lua for testing purposes")
return doc
end
10 changes: 10 additions & 0 deletions tests/docs/logging/lua-error.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "Lua Error Test"
format: html
filters:
- error-filter.lua
---

## Test Content

This document will trigger a Lua filter error because the error-filter.lua purposely generates an error.
Loading
Loading