Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ if ! [[ "${LOG_FD-}" =~ ^[0-9]+$ ]] || ! { : >&"${LOG_FD-2}"; } 2>/dev/null; the
exec {LOG_FD}>&1
fi

# ------------------------------------------------------------------------------
# Redirects the $LOG_FD fd to a changed STDOUT.
#
# If an add-on script changed the STDOUT (after the $LOG_FD fd was redirected to
# it, see above), this function redirects the $LOG_FD fd to the new STDOUT.
#
# Add-on developers must call this function after changing the STDOUT if they
# want the log functions to log to the new STDOUT.
# ------------------------------------------------------------------------------
function bashio::log.reinitialize_output() {
if [[ "${LOG_FD:-}" =~ ^[0-9]+$ ]] && { : >&"${LOG_FD}"; } 2>/dev/null; then
eval "exec ${LOG_FD}>&1"
fi
}

# ------------------------------------------------------------------------------
# Log a message to output.
#
Expand Down
Loading