๐Ÿ“‚ log

log::warning

Displays a warning.

  • $@: message as string: the warning messages to display
log::warning "This is a warning message."

log::isDebugEnabled

Check if the debug mode is enabled.

Returns:

  • $?:
    • 0 if debug mode is enabled (log level is debug)
    • 1 if disabled
if log::isDebugEnabled; then printf '%s\n' "Debug mode is active."; fi

log::setLevel

Set the log level.

  • $1: log level as string: the log level to set (or defaults to info), acceptable values are:
    • trace
    • debug
    • info
    • success
    • warning
    • error
  • $2: silent as bool: (optional) true to silently switch log level, i.e. does not print a message (defaults to false)
log::setLevel debug
log::setLevel debug true

log::printString

Display a string in the log. The string will be aligned with the current log output and hard wrapped if necessary. Does not check the log level.

  • $1: content as string: the content to log (can contain new lines)
  • $2: new line pad string as string: (optional) the string with which to prepend each wrapped line (empty by default)
log::printString "my line"

shellcheck disable=SC2317

log::trace

Displays a trace message.

  • $@: message as string: the trace messages to display
log::trace "This is a trace message."

log::success

Displays a success message.

  • $@: message as string: the success messages to display
log::success "This is a success message."

log::printCallStack

This function prints the current function stack in the logs.

  • $1: stack to skip as int: the number of stack to skip (defaults to 2 which skips this function and the first calling function which is usually the onError function)
log::printCallStack 2

log::isTraceEnabled

Check if the trace mode is enabled.

Returns:

  • $?:
    • 0 if trace mode is enabled (log level is trace)
    • 1 if disabled
if log::isTraceEnabled; then printf '%s\n' "Debug mode is active."; fi

log::printRaw

Display something in the log stream. Does not check the log level.

  • $1: content as string: the content to print (can contain new lines)
log::printRaw "my line"

shellcheck disable=SC2317

log::error

Displays an error message.

  • $@: message as string: the error messages to display
log::error "This is an error message."

You probably want to exit immediately after an error and should consider using core::fail function instead.

log::info

Displays an info message.

  • $@: message as string: the info messages to display
log::info "This is an info message."

log::printFileString

Display a file content with line numbers in the logs. The file content will be aligned with the current log output and hard wrapped if necessary.

  • $1: content as string: the file content.
  • $2: max lines as int: (optional) max lines to display (defaults to 0 which prints all lines).
log::printFileString "myfilecontent"

shellcheck disable=SC2317

log::debug

Displays a debug message.

  • $@: message as string: the debug messages to display
log::debug "This is a debug message."

log::getLevel

Get the current log level.

Returns:

  • RETURNED_VALUE: The current log level.
log::getLevel
printf '%s\n' "The log level is โŒœ${RETURNED_VALUE}โŒ."

log::printFile

Display a file content with line numbers in the logs. The file content will be aligned with the current log output and hard wrapped if necessary.

  • $1: path as string: the file path to display.
  • $2: max lines as int: (optional) max lines to display (defaults to 0 which prints all lines).
log::printFile "/my/file/path"

shellcheck disable=SC2317

log::errorTrace

Displays an error trace message. This is a trace message that is always displayed, independently of the log level. It can be used before a fatal error to display useful information.

  • $@: message as string: the trace messages to display
log::errorTrace "This is a debug message."

Documentation generated for the version 0.20.345 (2024-08-14).