Wire NOTE messages into CLI output with severity prefixes#292
Wire NOTE messages into CLI output with severity prefixes#292spe-ciellt merged 1 commit intogerbv:developfrom
Conversation
IssuesFragile quiet-mode comparison. GLib log levels are bitmasks, not an ordered scale — higher numeric values mean less severe: The condition: if (quietMode && level >= G_LOG_LEVEL_INFO)
goto handle_fatal;happens to suppress INFO and DEBUG correctly by accident, but reads as if INFO is "high severity". It also silently suppresses if (quietMode && (level & (G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG)))
goto handle_fatal;
One "message" prefix may confuse users.
Updating command line switches should update the man page as well. I'm not sure if is up to date, but from now I think it is good idea to keep that updated as well. |
GERBV_MESSAGE_NOTE messages were stored in the error list but never emitted to stderr, making them invisible in CLI mode. The log handler also used GLib's default format with no clean prefixes, and the --log flag was parsed but never connected. - Add GERB_NOTE macro mapping to G_LOG_LEVEL_INFO - Emit NOTE messages through g_log in gerb_stats.c - Replace g_log_default_handler with custom formatter that prints clean "fatal/error/warning/info/note:" prefixes to stderr - Add --quiet/-q flag to suppress note-level and debug messages - Wire up --log/-l to write prefixed messages to a file - Preserve GUI replay via log_array_tmp storage - Delegate to g_log_default_handler only for fatal (abort) - Parse --quiet in getopt pass 1 so it takes effect before pass 2 - Close log file on all exit paths for consistency - Update man page with -q/--quiet and revised -l/--log descriptions Fixes gerbv#291
ada0d95 to
7ab3584
Compare
|
Thanks for the thorough review. All six points addressed:
Force-pushed with |
|
One concern: I'm uneasy about the naming where G_LOG_LEVEL_MESSAGE maps to "info" and G_LOG_LEVEL_INFO maps to "note". It feels inverted — "message" becoming the more informational label and "info" being demoted to "note" reads backwards. Open to suggestions on better naming here. |
|
I agree with you. You can swap them around if you want to. I don't know if that will cause any problems in other part of the code. If it is too many changes in other places of the code maybe we should leave it at the moment and drop an issue for future reference? It would also be great if this could be documented somewhere. Currently I am a bit overwhelmed by all PRs coming in (I am positive, don't get me wrong). But keep this in mind for the future. ;) |
|
@spe-ciellt No urgency at all on any of our PRs — take your time. We really appreciate the decades of work you've put into gerbv, and the credit and attribution in the project. It's great to see a release happening after so long! On the naming swap: I checked the scope — |
Summary
GERB_NOTEmacro (G_LOG_LEVEL_INFO) and emit NOTE messages throughg_logingerb_stats.cg_log_default_handlerpassthrough with a custom formatter that prints cleanfatal:/error:/warning:/note:prefixes to stderr--quiet/-qflag to suppress note-level messages--log/-lflag to actually write prefixed messages to a fileContext
PR #282 (Gerber X2 attributes) added
GERBV_MESSAGE_NOTEmessages for X2 attribute commands. TheNOTEcase ingerbv_stats_add_error()had abreakwith nog_log()call — messages were stored in the error list but never emitted to stderr. Messages that did reach stderr used GLib's default format (** (process): WARNING **: text) with no clean prefix. The--logflag was parsed but never connected.Changes
src/gerbv.h—GERB_NOTE(...)macro mapping toG_LOG_LEVEL_INFOsrc/gerb_stats.c— Wire emptyGERBV_MESSAGE_NOTEcase toGERB_NOTE()src/main.c:callbacks_temporary_handle_log_messagesthat formats with severity prefixes, respects--quiet, writes to log file, and preserveslog_array_tmpfor GUI replay--quiet/-qoption (longopts, opt_options, switch case, help text)--log/-lfile open after option parsing,fcloseon both CLI exit and GUI return pathsTest plan
cd build && cmake .. && make— clean, no warnings--quiet: showsnote: Ignoring Gerber X2 attribute...--quiet: note suppressed, no outputerror:andwarning:prefixes shown correctly--log /tmp/gerbv.log: log file written with prefixed messagesFixes #291