update/software/scripts/shell-utils

36 lines
617 B
Plaintext

# !/bin/bash
#
# Copyright (c) 2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# File containing common shell functions that
# can be sourced and used by other shell scripts.
#
# If not specified by the importing
# script defaults to USM main log file
if [ -z $LOG_FILE ]; then
LOG_FILE="/var/log/software.log"
fi
log()
{
script_name=$(basename $0)
log_type=$1
shift
echo "$(date -Iseconds | cut -d'+' -f1): ${script_name}[${$}]: ${log_type}: ${@}" 2>&1 >> $LOG_FILE
}
info() {
log "INFO" $@
}
warning() {
log "WARNING" $@
}
error() {
log "ERROR" $@ >&2
}