Browse code

Merge pull request #11468 from stevekuznetsov/skuznets/bash-logging

Merged by openshift-bot

OpenShift Bot authored on 2016/11/04 16:04:04
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,48 @@
0
+#!/bin/bash
1
+
2
+# This file contains functions used for writing log messages
3
+# to stdout and stderr from scripts while they run.
4
+
5
+# os::log::info writes the message to stdout.
6
+#
7
+# Arguments:
8
+#  - all: message to write
9
+function os::log::info() {
10
+	echo "[INFO] $*"
11
+}
12
+readonly -f os::log::info
13
+
14
+# os::log::warn writes the message to stderr.
15
+# A warning indicates something went wrong but
16
+# not so wrong that we cannot recover.
17
+#
18
+# Arguments:
19
+#  - all: message to write
20
+function os::log::warn() {
21
+	os::text::print_yellow "[WARNING] $*\n" 1>&2
22
+}
23
+readonly -f os::log::warn
24
+
25
+# os::log::error writes the message to stderr.
26
+# An error indicates that something went wrong
27
+# and we will most likely fail after this.
28
+#
29
+# Arguments:
30
+#  - all: message to write
31
+function os::log::error() {
32
+	os::text::print_red "[ERROR] $*\n" 1>&2
33
+}
34
+readonly -f os::log::error
35
+
36
+# os::log::fatal writes the message to stderr and
37
+# returns a non-zero code to force a process exit.
38
+# A fatal error indicates that there is no chance
39
+# of recovery.
40
+#
41
+# Arguments:
42
+#  - all: message to write
43
+function os::log::fatal() {
44
+	os::text::print_red "[FATAL] $*\n" 1>&2
45
+	return 1
46
+}
47
+readonly -f os::log::fatal
0 48
\ No newline at end of file
... ...
@@ -300,29 +300,6 @@ readonly -f disable-selinux
300 300
 # end of common functions for extended test group's run.sh scripts
301 301
 ######
302 302
 
303
-function os::log::with-severity() {
304
-	local msg=$1
305
-	local severity=$2
306
-
307
-	echo "[$2] ${1}"
308
-}
309
-readonly -f os::log::with-severity
310
-
311
-function os::log::info() {
312
-	os::log::with-severity "${1}" "INFO"
313
-}
314
-readonly -f os::log::info
315
-
316
-function os::log::warn() {
317
-	os::log::with-severity "${1}" "WARNING" 1>&2
318
-}
319
-readonly -f os::log::warn
320
-
321
-function os::log::error() {
322
-	os::log::with-severity "${1}" "ERROR" 1>&2
323
-}
324
-readonly -f os::log::error
325
-
326 303
 function find_files() {
327 304
 	find . -not \( \
328 305
 		\( \