From f3ea6ab2a9ddd05c3d3603d38820d364d63e8772 Mon Sep 17 00:00:00 2001 From: Spencer Brower <6729162+sbrow@users.noreply.github.com> Date: Mon, 3 Aug 2026 16:38:16 -0400 Subject: [PATCH] feat: Added `-verbose` and `-quiet` flags to set the log level. --- TODOS.md | 2 +- main.odin | 13 ++++++++++++- site.odin | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/TODOS.md b/TODOS.md index e9d407d..f6af2ac 100644 --- a/TODOS.md +++ b/TODOS.md @@ -45,7 +45,7 @@ - [ ] talk about the context stack (and its limit). - [ ] highlight the differences in the way menus are handled. - [ ] consider sites with date based urls. -- [ ] Don't show annoying log output in tests. +- [x] Don't show annoying log output in tests. - [ ] improve home link customization. - [ ] currently an accessibility issue. - [x] support JSON5 in in frontmatter diff --git a/main.odin b/main.odin index 33140eb..a252a66 100644 --- a/main.odin +++ b/main.odin @@ -46,7 +46,18 @@ main :: proc() { logger_opts: log.Options = (log.Default_Console_Logger_Opts - log.Full_Timestamp_Opts - {.Short_File_Path}) - console_logger := log.create_console_logger(.Info, logger_opts) + level := log.Level.Info + for arg in os.args { + switch (arg) { + case "-verbose": + level = .Debug; + break + case "-quiet": + level = .Warning; + break + } + } + console_logger := log.create_console_logger(level, logger_opts) context.logger = console_logger defer log.destroy_console_logger(console_logger) diff --git a/site.odin b/site.odin index 60ea779..d711fa8 100644 --- a/site.odin +++ b/site.odin @@ -88,6 +88,8 @@ Flags :: struct { drafts: bool `args:"name=drafts" usage:"Include draft pages in the build"`, watch: bool `usage:"Rebuild on file changes (polls every 5 seconds)"`, minify: bool `args:"name=minify" usage:"Minify HTML output and CSS assets"`, + verbose: bool `usage:"Enable debug logging"`, + quiet: bool `usage:"Suppress info logging (warnings and errors only)"`, md_enable: string `args:"name=ext" usage:"Enable markdown extensions (comma-separated: emoji,sidenotes,alerts,highlight,sections)"`, md_disable: string `args:"name=no-ext" usage:"Disable markdown extensions (comma-separated: emoji,sidenotes,alerts,highlight,sections)"`, }