-
-
Notifications
You must be signed in to change notification settings - Fork 54
CLI output should differentiate message severity levels #291
Description
Problem
In CLI (non-GUI) mode, gerbv does not differentiate between message severity levels in its output. All messages from the GLib log handler are printed to stderr with the same format, making it impossible to distinguish errors from warnings or notes.
As noted during review of #282:
The NOTE vs ERROR distinction is only visible in the GUI Messages pane, not CLI output, so it can't be exercised by the automated suite.
The type system already exists — gerbv_message_type_t defines four levels (FATAL, ERROR, WARNING, NOTE) and error_type_string() in callbacks.c maps them to display strings. But this infrastructure is only used in the GUI.
Current architecture
Message type enum (gerbv.h:138-142)
typedef enum {
GERBV_MESSAGE_FATAL, // processing cannot continue
GERBV_MESSAGE_ERROR, // something went wrong, but processing can continue
GERBV_MESSAGE_WARNING, // something may provide wrong output
GERBV_MESSAGE_NOTE // irregularity, no intervention needed
} gerbv_message_type_t;GLib log macros (gerbv.h:120-123)
#define GERB_FATAL_ERROR(...) g_log(NULL, G_LOG_LEVEL_ERROR, __VA_ARGS__)
#define GERB_COMPILE_ERROR(...) g_log(NULL, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
#define GERB_COMPILE_WARNING(...) g_log(NULL, G_LOG_LEVEL_WARNING, __VA_ARGS__)
#define GERB_MESSAGE(...) g_log(NULL, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)There is no macro for NOTE-level messages. Notes are stored in the error list via gerbv_stats_add_error() but are not output to stderr in CLI mode.
CLI message handler (callbacks.c:375-386)
The temporary handler (callbacks_temporary_handle_log_messages) stores messages and delegates to g_log_default_handler(), which outputs to stderr without severity prefixes.
GUI handler (callbacks.c:3994-4081)
The GUI handler color-codes messages by level (red for errors, darkblue for messages, darkgreen for info, etc.) and routes them to the Messages pane. This distinction is lost in CLI mode.
Unused --log flag
The -l, --log=<logfile> CLI option is parsed (main.c:787-794) but the logToFileOption and logToFileFilename variables are never used — file logging is unimplemented.
Proposal
1. Add severity prefixes to CLI output
Replace or wrap the temporary log handler with a CLI-specific handler that prefixes messages:
error: Unknown RS-274X extension found %XX% at line 3 in file "..."
note: Gerber X2 file attribute %TF.GenerationSoftware% (ignored)
warning: Trailing garbage found after numeric data
2. Add a --verbosity flag
--verbosity=<level> Set minimum message level: fatal, error, warning, note (default: note)
--quiet Suppress note-level messages (equivalent to --verbosity=warning)
3. Implement the --log flag
The flag is already parsed but unused. Wire it up to write formatted messages to the specified file.
4. Add a GERB_NOTE() macro
#define GERB_NOTE(...) g_log(NULL, G_LOG_LEVEL_INFO, __VA_ARGS__)This gives NOTE-level messages a path to stderr output, consistent with the other macros.
Impact
- Makes CLI output machine-parseable (grep for
error:vsnote:) - Enables test suites to verify message levels (currently impossible per fix: silently ignore Gerber X2 attribute commands (TF, TA, TO, TD) #282 review)
- The
--quietflag would suppress the Gerber X2 attribute notes that originally prompted Unknown RS-274X extension found #249 - Completing
--logfinishes an existing but broken feature
Related
- fix: silently ignore Gerber X2 attribute commands (TF, TA, TO, TD) #282 — Gerber X2 attributes (review noted CLI limitation)
- Unknown RS-274X extension found #249 — Unknown RS-274X extension found (X2 attribute error spam)