Skip to content

build-scripts/functions: added logging functions #1813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

larsewi
Copy link
Contributor

@larsewi larsewi commented Jul 24, 2025

The main motivation for these functions is for them to include the
filename in the output. Hence, when things stop working, you'll know
exactly where to look.

Example file:

#!/bin/sh
. "$(dirname "$0")/functions"
log_debug foo bar baz
log_error bogus

Example output:

$ ./test.sh
test.sh: Debug: foo bar baz
test.sh: Error: bogus

Signed-off-by: Lars Erik Wik lars.erik.wik@northern.tech

@larsewi larsewi force-pushed the logging branch 2 times, most recently from 7e26800 to 43c7eb5 Compare July 24, 2025 09:51
The main motivation for these functions is for them to include the
filename in the output. Hence, when things stop working, you'll know
exactly where to look.

Example file:
```sh
. "$(dirname "$0")/functions"
log_debug foo bar baz
log_error bogus
```

Example output:
```
$ ./test.sh
test.sh: Debug: foo bar baz
test.sh: Error: bogus
```

Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@olehermanse olehermanse requested a review from vpodzime July 24, 2025 12:33
@olehermanse
Copy link
Member

GH Actions failure is unrelated.

Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me either way. Lovely!

@@ -617,4 +617,14 @@ run_and_print_on_failure()
return $exit_code
}

log_debug()
{
echo "$(basename "$0"): Debug:" "$@"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd do lowercase debug: and error: as that's more common.

@olehermanse olehermanse merged commit 1e4d8d6 into cfengine:master Jul 24, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants