ec2_post_init
Populate STScI EC2 instances with ease
io.inc.sh
Go to the documentation of this file.
1## @file
2## @brief Input output functions
3
4(( $EC2PINIT_IO_INCLUDED )) && return
5EC2PINIT_IO_INCLUDED=1
6source ec2pinit.inc.sh
7
8## Date format for IO functions
9io_datefmt="%Y-%m-%d %H:%M:%S"
11
12## @fn io_timestamp()
13## @brief Return current date and time
14## @retval date as string
16 date +"$io_datefmt"
17}
18
19## @fn io_info()
20## @brief Print a message
21## @param ... message arguments
22##
23## @code{.sh}
24## var=hello
25## ec2pinit_debug=$DEBUG_INFO
26## io_info "$var"
27## # 2022-06-22 18:46:57 - INFO: hello
28## @endcode
30 (( ec2pinit_debug & DEBUG_INFO )) || return 0
31 printf "$(io_timestamp) - INFO: %s\n" "$@" >&2
32}
33
34## @fn io_warn()
35## @brief Print a warning message
36## @param ... message arguments
37##
38## @code{.sh}
39## var=hello
40## ec2pinit_debug=$DEBUG_WARN
41## io_warn "uh oh... $var"
42## # 2022-06-22 18:46:57 - WARN: uh oh... hello
43## @endcode
45 (( ec2pinit_debug & DEBUG_WARN )) || return 0
46 printf "$(io_timestamp) - WARN: %s\n" "$@" >&2
47}
48
49## @fn io_error()
50## @brief Print an error message
51## @param ... message arguments
52##
53## @code{.sh}
54## var=hello
55## ec2pinit_debug=$DEBUG_ERROR
56## io_error "oh no... $var"
57## # 2022-06-22 18:46:57 - ERROR: oh no... hello
58## @endcode
60 (( ec2pinit_debug & DEBUG_ERROR )) || return 0
61 printf "$(io_timestamp) - ERROR: %s\n" "$@" >&2
62}
Exported String io_datefmt
Date format for IO functions.
Definition: io.inc.sh:10
io_timestamp()
Return current date and time.
Definition: io.inc.sh:15
io_warn(...)
Print a warning message.
Definition: io.inc.sh:44
io_info(...)
Print a message.
Definition: io.inc.sh:29
io_error(...)
Print an error message.
Definition: io.inc.sh:59
Exported String DEBUG_WARN
FLAG - Print warning messages.
Exported String ec2pinit_debug
Debug output control.
Exported String DEBUG_ERROR
FLAG - Print error messages.
Exported String DEBUG_INFO
FLAG - Print info messages.