diff --git a/templates/README.md.jinja b/templates/README.md.jinja index d1f7b2e..8fdbc09 100644 --- a/templates/README.md.jinja +++ b/templates/README.md.jinja @@ -82,7 +82,7 @@ how to install & manage versions. Plugins generated from asdf-plugin-template repository will contains several extra features for every user including all below. -- `$DEBUG=` to enabled debug mode +- `$DEBUG=` to enabled debug mode (debug logs will guarantee to show regardless of other settings) - `$ASDF_FORCE_DOWNLOAD=` to always download even cache exist - `$ASDF_INSECURE=` to disable security features (e.g. checksum) - `$ASDF_NO_CHECK=` to disable pre-check features (e.g. check-cmd) @@ -99,20 +99,23 @@ contains several extra features for every user including all below. - **{namespace}** - for formatted namespace (always have same length) - **{ns}** - for raw namespace (no formatting applied) - **{message}** - for log message +- `$ASDF_LOG_QUIET=` - to disable only info logs +- `$ASDF_LOG_SILENT=` - to disable all logs (including warning and error) ### Addition Features The plugins might contains additional features in addition to default features above. -You can take a look at [README.plugin.md][app-readme] +You can take a look at [README.plugin.md][app-readme-md] ## Contributors -Read [CONTRIBUTING.md] file for more detail. +Read [CONTRIBUTING.md][contributing-md] file for more detail. -[app-readme]: ./README.plugin.md +[app-readme-md]: ./README.plugin.md +[contributing-md]: ./CONTRIBUTING.md [plugin-gh]: {{ url(plugin_org, plugin_name) }} [template-gh]: https://github.com/kc-workspace/asdf-plugin-template [asdf-link]: https://github.com/asdf-vm/asdf diff --git a/templates/lib/common/internal.sh b/templates/lib/common/internal.sh index b0791e8..c6b04e5 100755 --- a/templates/lib/common/internal.sh +++ b/templates/lib/common/internal.sh @@ -32,10 +32,22 @@ __asdf_load() { ## usage: `kc_asdf_log '' '' '' ''` ## variables: ## - ASDF_LOG_FORMAT="{datetime} [{level}] {namespace} - {message}" +## - ASDF_LOG_QUIET=true +## - ASDF_LOG_SILENT=true __asdf_log() { local level="$1" ns="$2" _format="$3" shift 3 + case "$level" in + ## disable info logs if log_quiet or log_silent is set + "INF") + test -n "${ASDF_LOG_QUIET:-}" || test -n "${ASDF_LOG_SILENT:-}" && + return 0 + ;; + "WRN") test -n "${ASDF_LOG_SILENT:-}" && return 0 ;; + "ERR") test -n "${ASDF_LOG_SILENT:-}" && return 0 ;; + esac + local default="{time} [{level}] {namespace} - {message}" local template="${ASDF_LOG_FORMAT:-$default}"