summaryrefslogtreecommitdiff
path: root/src/lib/logging.source.sh
blob: b627b04460e72e6519143e531629b7f6f4fa5fd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Output/logging utilities. Split out of bootstrap.source.sh (task jn0) so the
# "how do we print to the user" concern lives apart from startup wiring and path
# resolution. These helpers read the SHURIKEN_OUTPUT_MODE global and are called
# from nearly every other module, so this file is kept early in LIB_SOURCES.
# All library modules are sourced before any code runs, so definition order does
# not affect availability.

output_is_quiet() {
    [ "$SHURIKEN_OUTPUT_MODE" = quiet ]
}

output_is_verbose() {
    [ "$SHURIKEN_OUTPUT_MODE" = verbose ]
}

log_info() {
    if ! output_is_quiet; then
        printf '%s\n' "$*"
    fi
}

log_verbose() {
    if output_is_verbose; then
        printf 'Verbose: %s\n' "$*"
    fi
}

log_warning() {
    printf 'WARNING: %s\n' "$*" >&2
}