mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
helpers: Drop obsolete/unused/weird logging helpers
This commit is contained in:
parent
e521fef23d
commit
910364f9c4
2 changed files with 12 additions and 98 deletions
|
@ -38,25 +38,6 @@ ynh_print_info() {
|
||||||
echo "$message" >&$YNH_STDINFO
|
echo "$message" >&$YNH_STDINFO
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ignore the yunohost-cli log to prevent errors with conditional commands
|
|
||||||
#
|
|
||||||
# [internal]
|
|
||||||
#
|
|
||||||
# usage: ynh_no_log COMMAND
|
|
||||||
#
|
|
||||||
# Simply duplicate the log, execute the yunohost command and replace the log without the result of this command
|
|
||||||
# It's a very badly hack...
|
|
||||||
#
|
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
|
||||||
ynh_no_log() {
|
|
||||||
local ynh_cli_log=/var/log/yunohost/yunohost-cli.log
|
|
||||||
cp --archive ${ynh_cli_log} ${ynh_cli_log}-move
|
|
||||||
eval $@
|
|
||||||
local exit_code=$?
|
|
||||||
mv ${ynh_cli_log}-move ${ynh_cli_log}
|
|
||||||
return $exit_code
|
|
||||||
}
|
|
||||||
|
|
||||||
# Main printer, just in case in the future we have to change anything about that.
|
# Main printer, just in case in the future we have to change anything about that.
|
||||||
#
|
#
|
||||||
# [internal]
|
# [internal]
|
||||||
|
@ -302,70 +283,3 @@ ynh_script_progression () {
|
||||||
ynh_return () {
|
ynh_return () {
|
||||||
echo "$1" >> "$YNH_STDRETURN"
|
echo "$1" >> "$YNH_STDRETURN"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Debugger for app packagers
|
|
||||||
#
|
|
||||||
# usage: ynh_debug [--message=message] [--trace=1/0]
|
|
||||||
# | arg: -m, --message= - The text to print
|
|
||||||
# | arg: -t, --trace= - Turn on or off the trace of the script. Usefull to trace nonly a small part of a script.
|
|
||||||
#
|
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
|
||||||
ynh_debug () {
|
|
||||||
# Disable set xtrace for the helper itself, to not pollute the debug log
|
|
||||||
set +o xtrace # set +x
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=mt
|
|
||||||
local -A args_array=( [m]=message= [t]=trace= )
|
|
||||||
local message
|
|
||||||
local trace
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
# Re-disable xtrace, ynh_handle_getopts_args set it back
|
|
||||||
set +o xtrace # set +x
|
|
||||||
message=${message:-}
|
|
||||||
trace=${trace:-}
|
|
||||||
|
|
||||||
if [ -n "$message" ]
|
|
||||||
then
|
|
||||||
ynh_print_log "[Debug] ${message}" >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$trace" == "1" ]
|
|
||||||
then
|
|
||||||
ynh_debug --message="Enable debugging"
|
|
||||||
set +o xtrace # set +x
|
|
||||||
# Get the current file descriptor of xtrace
|
|
||||||
old_bash_xtracefd=$BASH_XTRACEFD
|
|
||||||
# Add the current file name and the line number of any command currently running while tracing.
|
|
||||||
PS4='$(basename ${BASH_SOURCE[0]})-L${LINENO}: '
|
|
||||||
# Force xtrace to stderr
|
|
||||||
BASH_XTRACEFD=2
|
|
||||||
# Force stdout to stderr
|
|
||||||
exec 1>&2
|
|
||||||
fi
|
|
||||||
if [ "$trace" == "0" ]
|
|
||||||
then
|
|
||||||
ynh_debug --message="Disable debugging"
|
|
||||||
set +o xtrace # set +x
|
|
||||||
# Put xtrace back to its original fild descriptor
|
|
||||||
BASH_XTRACEFD=$old_bash_xtracefd
|
|
||||||
# Restore stdout
|
|
||||||
exec 1>&1
|
|
||||||
fi
|
|
||||||
# Renable set xtrace
|
|
||||||
set -o xtrace # set -x
|
|
||||||
}
|
|
||||||
|
|
||||||
# Execute a command and print the result as debug
|
|
||||||
#
|
|
||||||
# usage: ynh_debug_exec "your_command [ | other_command ]"
|
|
||||||
# | arg: command - command to execute
|
|
||||||
#
|
|
||||||
# When using pipes, double quotes are required - otherwise, this helper will run the first command, and the whole output will be sent through the next pipe.
|
|
||||||
#
|
|
||||||
# If the command to execute uses double quotes, they have to be escaped or they will be interpreted and removed.
|
|
||||||
#
|
|
||||||
# Requires YunoHost version 3.5.0 or higher.
|
|
||||||
ynh_debug_exec () {
|
|
||||||
ynh_debug --message="$(eval $@)"
|
|
||||||
}
|
|
||||||
|
|
|
@ -478,28 +478,28 @@ ynh_get_scalable_phpfpm () {
|
||||||
|
|
||||||
if [ $print -eq 1 ]
|
if [ $print -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_debug --message="Footprint=${footprint}Mb by pool."
|
ynh_print_warn --message="Footprint=${footprint}Mb by pool."
|
||||||
ynh_debug --message="Process manager=$php_pm"
|
ynh_print_warn --message="Process manager=$php_pm"
|
||||||
ynh_debug --message="Max RAM=${max_ram}Mb"
|
ynh_print_warn --message="Max RAM=${max_ram}Mb"
|
||||||
if [ "$php_pm" != "static" ]
|
if [ "$php_pm" != "static" ]
|
||||||
then
|
then
|
||||||
ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))"
|
ynh_print_warn --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))"
|
||||||
ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))"
|
ynh_print_warn --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))"
|
||||||
fi
|
fi
|
||||||
if [ "$php_pm" = "dynamic" ]
|
if [ "$php_pm" = "dynamic" ]
|
||||||
then
|
then
|
||||||
ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))"
|
ynh_print_warn --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))"
|
||||||
elif [ "$php_pm" = "static" ]
|
elif [ "$php_pm" = "static" ]
|
||||||
then
|
then
|
||||||
ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))"
|
ynh_print_warn --message="Estimated footprint=$(( $php_max_children * $footprint ))"
|
||||||
fi
|
fi
|
||||||
ynh_debug --message="\nRaw php-fpm values:"
|
ynh_print_warn --message="\nRaw php-fpm values:"
|
||||||
ynh_debug --message="pm.max_children = $php_max_children"
|
ynh_print_warn --message="pm.max_children = $php_max_children"
|
||||||
if [ "$php_pm" = "dynamic" ]
|
if [ "$php_pm" = "dynamic" ]
|
||||||
then
|
then
|
||||||
ynh_debug --message="pm.start_servers = $php_start_servers"
|
ynh_print_warn --message="pm.start_servers = $php_start_servers"
|
||||||
ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers"
|
ynh_print_warn --message="pm.min_spare_servers = $php_min_spare_servers"
|
||||||
ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers"
|
ynh_print_warn --message="pm.max_spare_servers = $php_max_spare_servers"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue