[IMP] add structured logging functions

Add logging functions to lib/common.sh for consistent output formatting:
- log_info(): Standard informational messages with [INFO] prefix
- log_warn(): Warning messages to stderr with [WARN] prefix
- log_error(): Error messages to stderr with [ERROR] prefix
- log_step(): Section headers with visual separators

Update upgrade.sh to use these functions throughout, replacing ad-hoc
echo statements. This provides:
- Consistent visual formatting across all scripts
- Clear distinction between info, warnings and errors
- Errors properly sent to stderr
- Easier log parsing and filtering

Also removed redundant '|| exit 1' statements since set -e handles
command failures automatically.
This commit is contained in:
Stéphan Sainléger
2026-02-02 17:58:42 +01:00
parent 914ae34f12
commit d3f0998036
2 changed files with 50 additions and 92 deletions

View File

@@ -9,6 +9,11 @@ set -euo pipefail
readonly DATASTORE_PATH="/srv/datastore/data"
readonly FILESTORE_SUBPATH="var/lib/odoo/filestore"
log_info() { printf "[INFO] %s\n" "$*"; }
log_warn() { printf "[WARN] %s\n" "$*" >&2; }
log_error() { printf "[ERROR] %s\n" "$*" >&2; }
log_step() { printf "\n===== %s =====\n" "$*"; }
query_postgres_container() {
local query="$1"
local db_name="$2"
@@ -58,4 +63,5 @@ exec_python_script_in_odoo_shell() {
}
export DATASTORE_PATH FILESTORE_SUBPATH
export -f log_info log_warn log_error log_step
export -f query_postgres_container copy_database copy_filestore exec_python_script_in_odoo_shell