From dc07baeb4b5443131e0bd7f2c5f3b506e23d74dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Fri, 27 Aug 2021 20:51:14 +0200 Subject: Implements localised message files, pt. II. --- subr.rtl/rtl_log.subr | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'subr.rtl/rtl_log.subr') diff --git a/subr.rtl/rtl_log.subr b/subr.rtl/rtl_log.subr index 0a1e275b..3a7560a5 100644 --- a/subr.rtl/rtl_log.subr +++ b/subr.rtl/rtl_log.subr @@ -11,7 +11,15 @@ RTLP_LOG_NO_ATTR=0; RTLP_LOG_TAGS=""; rtlp_log_printf() { - local _attr="${1}" _fmt="${2}"; shift 2; _msg="$(printf "${_fmt}" "${@}")"; + local _attr="${1}" _fmt_pfx="${2}" _fmt="${3#*;}" _fmt_argc="${3%%;*}"; shift 3; + if [ "${#}" -ne "${_fmt_argc}" ]; then + if [ "${_fmt_argc}" -eq 0 ]; then + shift "${#}"; + else + rtlp_log_printf "" "" "0;==> FIXME TODO XXX MESSAGE STRING ARGUMENT COUNT MISMATCH\n"; + fi; + fi; + _msg="$(printf "${_fmt_pfx}${_fmt}" "${@}")"; if [ -n "${RTLP_LOG_FNAME}" ]; then printf "%s\n" "${_msg}" >> "${RTLP_LOG_FNAME}"; @@ -43,11 +51,11 @@ rtl_log_enable_tags() { rtl_log_env_vars() { local _tag="${1}" _type="${2}" _arg_len_max=0; shift 2; - rtl_log_msg "${_tag}" "Variables for this ${_type}:"; + rtl_log_msg "${_tag}" "${MSG_rtl_log_vars_header}" "${_type}"; _arg_len_max="$(rtl_lmax "${@}")"; while [ "${#}" -gt 0 ]; do - rtl_log_msg "${_tag}" \ - "%${_arg_len_max}.${_arg_len_max}s=%s" \ + rtl_log_msg "${_tag}" \ + "2;%${_arg_len_max}.${_arg_len_max}s=%s" \ "${1%%=*}" "$(rtl_get_var_unsafe "${1#*=}")"; shift; done; return 0; @@ -60,9 +68,9 @@ rtl_log_msg() { if rtl_lmatch "${RTLP_LOG_TAGS}" "${_tag}" ","; then eval _attr='${LOG_TAG_'"${_tag}"':-}'; if [ "${#_attr}" -eq 0 ]; then - rtlp_log_printf "" "==> FIXME TODO XXX UNKNOWN TAG \`%s' PASSED TO rtl_log_msg()\n" "${_tag}"; + rtlp_log_printf "" "" "0;==> FIXME TODO XXX UNKNOWN TAG \`${_tag}' PASSED TO rtl_log_msg()\n"; fi; - rtlp_log_printf "${_attr}" "==> %s ${_fmt}" "$(rtl_date)" "${@}"; + rtlp_log_printf "${_attr}" "==> $(rtl_date) " "${_fmt}" "${@}"; if [ "${_exitfl}" -eq 1 ]; then exit 1; fi; -- cgit v1.2.3