1.3 KiB
1.3 KiB
The utilities functions available at src/utility.sh
provide functionality that is either very simple in purpose or general to the whole application.
The two utility functions presently implemented are:
log <level> <message>
prepare_directories
log
This utility takes a log level as its first argument and a message as its second argument. The log message must be wrapped in double quotes, otherwise only the first word will be considered part of the message and the rest will be discarded.
The current log levels are:
debug
: Displays only whenDEBUG
is set in the environment with a nanosecond-precision timestamp. The valueDEBUG
is set to does not matter. To disable the log messages, unsetDEBUG
, for example, withexport DEBUG=
orunset DEBUG
user
: Always displays, with[tori]
at the very left followed by a second-precision timestamp, a colon and the messagefatal
: Always displays, exactly as in theuser
level
For now, all log messages are printed to STDERR
so as not to shadow function return values.
prepare_directories
prepare_directories
runs at the very start of execution in order to verify that critical directories exist. These directories are:
TMP_DIR
, default/tmp/tori
: created if not foundCONFIG_ROOT
, default~/.config/tori
: application exits with an error and exit code 1 if not found