Skip to content
Snippets Groups Projects
  • Simon McVittie's avatar
    dbf21961
    pressure-vessel: Put apt-style severity prefixes on messages · dbf21961
    Simon McVittie authored
    
    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>
    dbf21961
    History
    pressure-vessel: Put apt-style severity prefixes on messages
    Simon McVittie authored
    
    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>
utils.c 30.90 KiB