TT#65907 Write ngcpcfg PID into ngcpcfg.log file

It should simplify debug when two ngcpcfg executed in parallel.

Change-Id: I5fa77bfe9419c3cff798eaefbdb02f159b7b63c9
changes/40/30940/14
Alexander Lutay 7 years ago
parent 1141490a64
commit f4e5c0b645

@ -22,29 +22,29 @@ console_output() {
## logging functions {{{
log_info() {
logger -t ngcpcfg -- "$*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "$*"
console_output "$*\n"
}
# info without ending newline
log_info_n() {
logger -t ngcpcfg -- "$*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "$*"
console_output "$*"
}
log_warn() {
logger -t ngcpcfg -- "Warning: $*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Warning: $*"
console_output "Warning: $*\n"
}
log_error() {
logger -t ngcpcfg -- "Error: $*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Error: $*"
console_output "Error: $*\n" >&2
}
log_debug() {
if [ -n "${DEBUG:-}" ] ; then
logger -t ngcpcfg -- "Debug: $*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Debug: $*"
console_output "DEBUG: $*\n" >&2
fi
}

@ -109,6 +109,10 @@ fi
# Notify subprocesses we are running.
export NGCPCFG_RUNNING=1
export NGCPCFG_PID=$$
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "******************************************************"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Running: $0 $*"
# support for testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
SCRIPTS="${SCRIPTS:-/usr/share/ngcp-ngcpcfg/scripts/}"
@ -125,7 +129,7 @@ if [[ "${1:-}" == "decrypt" ]] ; then
# the part we need for executing ngcpcfg itself
log_debug() {
if [ -n "${DEBUG:-}" ] ; then
logger -t ngcpcfg -- "Debug: $*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Debug: $*"
echo ; echo "DEBUG: $*" ; echo # newlines to avoid messup with cmdline output
fi
}

@ -34,10 +34,14 @@ cd "$NGCPCTL_MAIN"
if [ -z "${NO_DB_SYNC:-}" ] ; then
if [ -f "${RTP_INTERFACES_CONFIG}" ] ; then
log_info "Executing sync-db: "
"${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" "$RTP_INTERFACES_CONFIG" 2>&1 | sed "s/^/$timestamp_replacementchars/" 2>&1 | tee >(logger -t ngcpcfg) || true
"${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" "$RTP_INTERFACES_CONFIG" 2>&1 | \
sed "s/^/$timestamp_replacementchars/" 2>&1 | \
tee >(logger -t ngcpcfg --id="${NGCPCFG_PID}") || true
else
log_info "Executing sync-db: "
"${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" 2>&1 | sed "s/^/$timestamp_replacementchars/" 2>&1 | tee >(logger -t ngcpcfg) || true
"${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" 2>&1 | \
sed "s/^/$timestamp_replacementchars/" 2>&1 | \
tee >(logger -t ngcpcfg --id="${NGCPCFG_PID}") || true
fi
else
log_debug "no-db-sync: skipping 'sync-db'"

@ -29,29 +29,29 @@ console_output() {
}
log_info() {
logger -t ngcpcfg -- "$*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "$*"
console_output "$*\n"
}
# info without ending newline
log_info_n() {
logger -t ngcpcfg -- "$*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "$*"
console_output "$*"
}
log_warn() {
logger -t ngcpcfg -- "Warning: $*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Warning: $*"
console_output "Warning: $*\n"
}
log_error() {
logger -t ngcpcfg -- "Error: $*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Error: $*"
console_output "Error: $*\n" >&2
}
log_debug() {
if [ -n "${DEBUG:-}" ] ; then
logger -t ngcpcfg -- "Debug: $*"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Debug: $*"
console_output "DEBUG: $*\n"
fi
}

Loading…
Cancel
Save