Improve logging with optional verbose comment #71

Merged
benpro merged 4 commits from verbose-logging into master 2019-03-21 14:27:38 +01:00
Owner

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 optional verbose "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, every echo "IS_XYZ FAILED!" can be changed to failed "IS_XYZ" with a search/replace.

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 optional `verbose "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, every `echo "IS_XYZ FAILED!"` can be changed to `failed "IS_XYZ"` with a search/replace.
benpro was assigned by jlecour 2019-03-20 22:41:33 +01:00
Author
Owner

Having a centralized logging function will also help to decide if we want to log to stdout or stderr, to a file…

Having a centralized logging function will also help to decide if we want to log to stdout or stderr, to a file…
Contributor

LGTM

LGTM
benpro reviewed 2019-03-21 10:53:17 +01:00
evocheck.sh Outdated
@ -131,1 +128,3 @@
[ "${VERBOSE}" -eq 1 ] && [ -n "${msg}" ] && echo "${msg}"
# logging function
failed() {
test=$1
Contributor

I don't like the name test for a variable. It could be the internal keyword test.
IMO we should choose another name.

I don't like the name `test` for a variable. It could be the internal keyword `test`. 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"
Contributor

Indeed, looks way better/cleaner.

Indeed, looks way better/cleaner.
benpro added the
enhancement
label 2019-03-21 10:54:26 +01:00
Author
Owner

@benpro I've changed the variable names. You were right, it's better

@benpro I've changed the variable names. You were right, it's better
Author
Owner

And I've changed all call to echo with failed.

And I've changed all call to `echo` with `failed`.
benpro reviewed 2019-03-21 14:06:32 +01:00
evocheck.sh Outdated
@ -132,0 +129,4 @@
failed() {
check_name=$1
shift
checl_comments=$@
Contributor

Typo I guess. :)

Typo I guess. :)
Author
Owner

fixed :/

fixed :/
jlecour changed title from WIP: Improve logging with optional verbose comment to Improve logging with optional verbose comment 2019-03-21 14:17:19 +01:00
Ghost approved these changes 2019-03-21 14:21:33 +01:00
benpro approved these changes 2019-03-21 14:27:07 +01:00
benpro closed this pull request 2019-03-21 14:27:38 +01:00
jlecour deleted branch verbose-logging 2019-03-21 20:38:16 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: evolix/evocheck#71
No description provided.