You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.9 KiB
71 lines
1.9 KiB
From 2364eff6a6837ae4418f1876f7f29459fdeec3bb Mon Sep 17 00:00:00 2001 |
|
From: Lars Ellenberg <lars.ellenberg@linbit.com> |
|
Date: Mon, 22 Sep 2014 15:26:59 +0200 |
|
Subject: [PATCH 4/6] Fix: ha_log: drop global __ha_log_ignore_stderr_once hack |
|
|
|
Use a helper function instead, |
|
which understands --ignore-stderr as first parameter. |
|
--- |
|
heartbeat/ocf-shellfuncs.in | 23 +++++++++-------------- |
|
1 file changed, 9 insertions(+), 14 deletions(-) |
|
|
|
diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in |
|
index c370fca..fd916e7 100644 |
|
--- a/heartbeat/ocf-shellfuncs.in |
|
+++ b/heartbeat/ocf-shellfuncs.in |
|
@@ -43,14 +43,6 @@ unset LANGUAGE; export LANGUAGE |
|
|
|
__SCRIPT_NAME=`basename $0` |
|
|
|
-# This is internal to shellfuncs. |
|
-# When set, ha_log can be used in a way that guarantees |
|
-# that stderr will not be printed to. This allows us to |
|
-# use ocf_exit_reason to print a string to stderr and use |
|
-# ha_log to print the same string to the other log facilities |
|
-# without having duplicate messages sent to stderr. |
|
-__ha_log_ignore_stderr_once="" |
|
- |
|
if [ -z "$OCF_ROOT" ]; then |
|
: ${OCF_ROOT=@OCF_ROOT_DIR@} |
|
fi |
|
@@ -189,12 +181,11 @@ set_logtag() { |
|
fi |
|
} |
|
|
|
-ha_log() { |
|
- local ignore_stderr="$__ha_log_ignore_stderr_once" |
|
+__ha_log() { |
|
+ local ignore_stderr=false |
|
local loglevel |
|
|
|
- # always reset this variable |
|
- __ha_log_ignore_stderr_once="" |
|
+ [ "x$1" = "x--ignore-stderr" ] && ignore_stderr=true && shift |
|
|
|
[ none = "$HA_LOGFACILITY" ] && HA_LOGFACILITY="" |
|
# if we're connected to a tty, then output to stderr |
|
@@ -257,6 +248,11 @@ ha_log() { |
|
fi |
|
} |
|
|
|
+ha_log() |
|
+{ |
|
+ __ha_log "$@" |
|
+} |
|
+ |
|
ha_debug() { |
|
|
|
if [ "x${HA_debug}" = "x0" ] ; then |
|
@@ -383,8 +379,7 @@ ocf_exit_reason() |
|
|
|
msg=$(printf "${fmt}" "$@") |
|
printf >&2 "%s%s\n" "$cookie" "$msg" |
|
- __ha_log_ignore_stderr_once="true" |
|
- ha_log "ERROR: $msg" |
|
+ __ha_log --ignore-stderr "ERROR: $msg" |
|
} |
|
|
|
# |
|
-- |
|
1.8.4.2 |
|
|
|
|