Package: lsb-base Severity: wishlist Tags: patch From 58dd6e6add24a4e5531a84ff2404f2f5ed71e114 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov <KAction@debian.org> Date: Sat, 11 May 2019 21:20:48 +0000 Subject: [PATCH] Introduce logging functions that check ${VERBOSE} Use of logging functions in initscripts are often conditioned on value of $VERBOSE variable, causing same code to be repeated over and over again. This change introduce number of logging functions (with prefix "v") that are functionally equivalent to their counterparts without prefix when value of $VERBOSE is not "no", and do nothing if value of $VERBOSE is "no". --- conf/conf.yaml | 7 +++++++ debian/control | 1 + debian/lsb-base.install | 1 + debian/rules | 4 ++++ init-functions.d/.gitignore | 1 + init-functions.d/00-verbose.jinja | 9 +++++++++ 6 files changed, 23 insertions(+) create mode 100644 conf/conf.yaml create mode 100644 init-functions.d/.gitignore create mode 100644 init-functions.d/00-verbose.jinja diff --git a/conf/conf.yaml b/conf/conf.yaml new file mode 100644 index 0000000..d1ac18b --- /dev/null +++ b/conf/conf.yaml @@ -0,0 +1,7 @@ +log_functions: + - log_daemon_msg + - log_begin_msg + - log_end_msg + - log_action_msg + - log_action_begin_msg + - log_action_end_msg diff --git a/debian/control b/debian/control index b39cdc6..e4746d2 100644 --- a/debian/control +++ b/debian/control @@ -9,6 +9,7 @@ Build-Depends: debhelper (>> 11~), python3-all:any, dh-python, distro-info-data, + ionit Standards-Version: 4.2.1 Homepage: https://wiki.linuxfoundation.org/lsb/start Vcs-Browser: https://salsa.debian.org/debian/lsb diff --git a/debian/lsb-base.install b/debian/lsb-base.install index 66dc0df..d2d9588 100644 --- a/debian/lsb-base.install +++ b/debian/lsb-base.install @@ -1,2 +1,3 @@ init-functions /lib/lsb +init-functions.d/00-verbose /lib/lsb/init-functions.d init-functions.d/20-left-info-blocks /lib/lsb/init-functions.d diff --git a/debian/rules b/debian/rules index 33c4aff..32789c5 100755 --- a/debian/rules +++ b/debian/rules @@ -8,6 +8,10 @@ PY3VERSIONS=$(shell [ -x /usr/bin/py3versions ] && py3versions -vr) %: dh $@ --with python3 +override_dh_auto_build: + dh_auto_build + ionit -c conf -t init-functions.d + # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) diff --git a/init-functions.d/.gitignore b/init-functions.d/.gitignore new file mode 100644 index 0000000..876584d --- /dev/null +++ b/init-functions.d/.gitignore @@ -0,0 +1 @@ +00-verbose diff --git a/init-functions.d/00-verbose.jinja b/init-functions.d/00-verbose.jinja new file mode 100644 index 0000000..15916aa --- /dev/null +++ b/init-functions.d/00-verbose.jinja @@ -0,0 +1,9 @@ +## Generated automatically. Do not edit! -*- shell-script -*- +{% for fn in log_functions %} +v{{ fn }} () { + if test "${VERBOSE:-yes}" != no ; then + {{ fn }} "$@" + fi +} +{% endfor %} +# vim: ft=sh -- Note, that I send and fetch email in batch, once every 24 hours. If matter is urgent, try https://t.me/kaction --
Attachment:
pgp480_5fvZq1.pgp
Description: PGP signature