Skip to content

CLI output should differentiate message severity levels #291

@rampageservices

Description

@rampageservices

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

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions