Skip to content
Snippets Groups Projects

pressure-vessel: Put apt-style severity prefixes on messages

Merged Simon McVittie requested to merge wip/message-prefix into master
Compare changes
  • Side-by-side
  • Inline
Files
6
  • These indicate which lines are harmless and which lines are really bad,
    without taking up too much space.
    
    The mapping from GLib log level to message is not 100% obvious, because
    G_LOG_LEVEL_ERROR is "worse than" an error. We diagnose "can't happen"
    situations (assertion failures, etc.) as "Internal error". Ideally,
    users should never see these: they indicate a bug.
    
    For situations that will cause pressure-vessel to exit with an error,
    introduce a new log level flag PV_LOG_LEVEL_FAILURE and map it to the
    apt-style "E:" prefix. pv_log_failure() is a convenience macro to log
    at level PV_LOG_LEVEL_FAILURE. Conceptually this is a fatal error, but
    it's a fatal error prompted by something external to pressure-vessel,
    for which we want pressure-vessel to clean up "nicely" and exit
    gracefully, even though it's going to fail - so we can't use g_error()
    for this.
    
    In the parts of main() that involve parsing command-line arguments,
    add usage_error() as syntactic sugar for pv_log_failure(). I might
    eventually turn these into G_OPTION_ERROR_FAILED as we factor out
    more of main() into helper functions, but for now they're handled
    separately.
    
    For less-severe log levels, use single-letter prefixes similar to apt's.
    
    Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
Loading