Github repo: https://github.com/filmil/fshlib
fshlib
fshlib is a simple shell library for logging. It provides a set of functions to log messages with different severity levels.
Usage
To use the library, source the log.bash file in your script:
source "path/to/log.bash"
Then you can use the logging functions:
log::info "This is an info message"
log::warn "This is a warning message"
log::error "This is an error message"
Functions
log::info: Logs an informational message.log::warn: Logs a warning message.log::error: Logs an error message.log::debug: Logs a debug message. This message is only shown if theDEBUGenvironment variable is set totrueorlog.log::prefix: Prefixes each line of the input with a given string.
Example
#!/usr/bin/env bash
source "path/to/log.bash"
log::info "Starting the script"
log::warn "Something might be wrong"
log::error "Something went wrong"
echo "some output" | log::prefix "[my-prefix] "