1 # Include for convenience log functions
2 # Set _log_to_stderr to send messages to stderr as well, for logging
5 Copyright (c) 2000-2012, CyberLeo
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
11 * Redistributions of the source code must retain the above copyright
12 notice, this list of conditions, and the following disclaimer.
13 * Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions, and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
16 * Neither the name of the organization nor the names of its contributors
17 may be used to endorse or promote products derived from this software
18 without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
26 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 HOWEVER CAUSED AND ON ANY THEORY OF LIABILTY, WHETHER IN CONTRACT, STRICT
28 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 if [ -z "${__log_sh_loaded}" ]
41 [ -n "${_log_to_stderr}" ] && printf "${@}" >&2
46 printf " ${a_cyan}*${a_normal} "
48 [ -n "${_log_to_stderr}" ] && echo "* note: ${*}" >&2
53 printf " ${a_green}*${a_normal} "
55 [ -n "${_log_to_stderr}" ] && echo "* log: ${*}" >&2
61 printf " ${a_yellow}*${a_normal} "
63 [ -n "${_log_to_stderr}" ] && echo "* warn: ${*}" >&2
69 printf " ${a_red}*${a_normal} "
71 [ -n "${_log_to_stderr}" ] && echo "* err: ${*}" >&2
85 [ -n "${*}" ] && echo " ${a_red}*${a_normal} in '$(pwd)': cmd '${*}' failed with status ${_res}"
86 [ -n "${out}" ] && printf " ${a_red}*${a_normal} Output:\n${out}\n"