mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
parent
b52297b8e1
commit
9550bf3eb1
1 changed files with 99 additions and 4 deletions
|
@ -8,12 +8,11 @@ ynh_die() {
|
||||||
# Display a message in the 'INFO' logging category
|
# Display a message in the 'INFO' logging category
|
||||||
#
|
#
|
||||||
# usage: ynh_info "Some message"
|
# usage: ynh_info "Some message"
|
||||||
ynh_info()
|
ynh_print_info() {
|
||||||
{
|
echo "$1" >> "$YNH_STDINFO"
|
||||||
echo "$1" >>"$YNH_STDINFO"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ignore the yunohost-cli log to prevent errors with conditionals commands
|
# Ignore the yunohost-cli log to prevent errors with conditional commands
|
||||||
#
|
#
|
||||||
# [internal]
|
# [internal]
|
||||||
#
|
#
|
||||||
|
@ -29,3 +28,99 @@ ynh_no_log() {
|
||||||
sudo mv ${ynh_cli_log}-move ${ynh_cli_log}
|
sudo mv ${ynh_cli_log}-move ${ynh_cli_log}
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Main printer, just in case in the future we have to change anything about that.
|
||||||
|
#
|
||||||
|
# [internal]
|
||||||
|
#
|
||||||
|
ynh_print_log () {
|
||||||
|
echo -e "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Print a warning on stderr
|
||||||
|
#
|
||||||
|
# usage: ynh_print_warn "Text to print"
|
||||||
|
# | arg: text - The text to print
|
||||||
|
ynh_print_warn () {
|
||||||
|
ynh_print_log "\e[93m\e[1m[WARN]\e[0m ${1}" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# Print an error on stderr
|
||||||
|
#
|
||||||
|
# usage: ynh_print_err "Text to print"
|
||||||
|
# | arg: text - The text to print
|
||||||
|
ynh_print_err () {
|
||||||
|
ynh_print_log "\e[91m\e[1m[ERR]\e[0m ${1}" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute a command and print the result as an error
|
||||||
|
#
|
||||||
|
# usage: ynh_exec_err command to execute
|
||||||
|
# usage: ynh_exec_err "command to execute | following command"
|
||||||
|
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be sent to the next pipe.
|
||||||
|
#
|
||||||
|
# | arg: command - command to execute
|
||||||
|
ynh_exec_err () {
|
||||||
|
ynh_print_err "$(eval $@)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute a command and print the result as a warning
|
||||||
|
#
|
||||||
|
# usage: ynh_exec_warn command to execute
|
||||||
|
# usage: ynh_exec_warn "command to execute | following command"
|
||||||
|
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be sent to the next pipe.
|
||||||
|
#
|
||||||
|
# | arg: command - command to execute
|
||||||
|
ynh_exec_warn () {
|
||||||
|
ynh_print_warn "$(eval $@)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute a command and force the result to be printed on stdout
|
||||||
|
#
|
||||||
|
# usage: ynh_exec_warn_less command to execute
|
||||||
|
# usage: ynh_exec_warn_less "command to execute | following command"
|
||||||
|
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be sent to the next pipe.
|
||||||
|
#
|
||||||
|
# | arg: command - command to execute
|
||||||
|
ynh_exec_warn_less () {
|
||||||
|
eval $@ 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute a command and redirect stdout in /dev/null
|
||||||
|
#
|
||||||
|
# usage: ynh_exec_quiet command to execute
|
||||||
|
# usage: ynh_exec_quiet "command to execute | following command"
|
||||||
|
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be sent to the next pipe.
|
||||||
|
#
|
||||||
|
# | arg: command - command to execute
|
||||||
|
ynh_exec_quiet () {
|
||||||
|
eval $@ > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute a command and redirect stdout and stderr in /dev/null
|
||||||
|
#
|
||||||
|
# usage: ynh_exec_fully_quiet command to execute
|
||||||
|
# usage: ynh_exec_fully_quiet "command to execute | following command"
|
||||||
|
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be sent to the next pipe.
|
||||||
|
#
|
||||||
|
# | arg: command - command to execute
|
||||||
|
ynh_exec_fully_quiet () {
|
||||||
|
eval $@ > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove any logs for all the following commands.
|
||||||
|
#
|
||||||
|
# usage: ynh_print_OFF
|
||||||
|
# WARNING: You should be careful with this helper, and never forget to use ynh_print_ON as soon as possible to restore the logging.
|
||||||
|
ynh_print_OFF () {
|
||||||
|
set +x
|
||||||
|
}
|
||||||
|
|
||||||
|
# Restore the logging after ynh_print_OFF
|
||||||
|
#
|
||||||
|
# usage: ynh_print_ON
|
||||||
|
ynh_print_ON () {
|
||||||
|
set -x
|
||||||
|
# Print an echo only for the log, to be able to know that ynh_print_ON has been called.
|
||||||
|
echo ynh_print_ON > /dev/null
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue