Improve logging with optional verbose comment #71
No reviewers
Labels
No labels
bug
bullseye
discussion
duplicate
enhancement
help wanted
invalid
question
suggestion
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: evolix/evocheck#71
Loading…
Reference in a new issue
No description provided.
Delete branch "verbose-logging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I think the verbose mode is a really great idea and I'd like to go further.
I've never liked the low-level
echo "IS_XYZ FAILED!"
statement, duplicated everywhere, with optionalverbose "message"
juste after them.I think we can have a single function to log failures and their optional comment.
If we need to change the way we log, there only one change to do.
In this first commit I've added the function and changed the failure logging only where there is a
verbose
call, to illustrate my idea. Obviously if this is confirmed as a good idea, everyecho "IS_XYZ FAILED!"
can be changed tofailed "IS_XYZ"
with a search/replace.Having a centralized logging function will also help to decide if we want to log to stdout or stderr, to a file…
LGTM
@ -131,1 +128,3 @@
[ "${VERBOSE}" -eq 1 ] && [ -n "${msg}" ] && echo "${msg}"
# logging function
failed() {
test=$1
I don't like the name
test
for a variable. It could be the internal keywordtest
.IMO we should choose another name.
@ -269,3 +276,2 @@
if is_installed apt-listchanges; then
echo 'IS_LISTCHANGESCONF FAILED!'
verbose "apt-listchanges must not be installed on Stretch"
failed "IS_LISTCHANGESCONF" "apt-listchanges must not be installed on Stretch"
Indeed, looks way better/cleaner.
@benpro I've changed the variable names. You were right, it's better
And I've changed all call to
echo
withfailed
.@ -132,0 +129,4 @@
failed() {
check_name=$1
shift
checl_comments=$@
Typo I guess. :)
fixed :/
WIP: Improve logging with optional verbose commentto Improve logging with optional verbose comment