From f80010e40aeec46737ec7e8bfa38a5ce93a9f968 Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Sat, 20 Feb 2021 11:56:51 +0100 Subject: [PATCH 1/3] feat: Multiple log line message are now split and log line by line for a nicest display --- CHANGELOG.md | 5 +++++ image/tool/log-helper | 7 ++++++- image/tool/run | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4667fcf8..57c4d3b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +# [1.4.0] - Unreleased +### Changed + - Multiple log line message are now split and log line by line for a nicest display. + # [1.3.2] - 2021-02-18 ### Fixed - Remove -x bash flag on log-helper tool @@ -172,6 +176,7 @@ ## 0.1.0 - 2015-07-23 Initial release +[1.4.0]: https://github.com/osixia/docker-light-baseimage/compare/v1.3.2...v1.4.0 [1.3.2]: https://github.com/osixia/docker-light-baseimage/compare/v1.3.1...v1.3.2 [1.3.1]: https://github.com/osixia/docker-light-baseimage/compare/v1.3.0...v1.3.1 [1.3.0]: https://github.com/osixia/docker-light-baseimage/compare/v1.2.0...v1.3.0 diff --git a/image/tool/log-helper b/image/tool/log-helper index e5f9fd13..f8bc6036 100755 --- a/image/tool/log-helper +++ b/image/tool/log-helper @@ -33,7 +33,12 @@ function print_log(){ local level_txt=$1 local message=$2 local date=$(date +"%Y-%m-%d %T") - echo "*** ${level_txt} | ${date} | ${message}" + + readarray -t messages <<<"$message" + + for m in "${messages[@]}"; do + echo "*** ${level_txt} | ${date} | ${m}" + done } function error() { diff --git a/image/tool/run b/image/tool/run index 7516d207..1f04a553 100755 --- a/image/tool/run +++ b/image/tool/run @@ -52,7 +52,8 @@ class AlarmException(Exception): def write_log(level, message): now = datetime.now() - sys.stderr.write("*** %s | %s | %s\n" % (level, now.strftime("%Y-%m-%d %H:%M:%S"), message)) + for line in message.splitlines(): + sys.stderr.write("*** %s | %s | %s\n" % (level, now.strftime("%Y-%m-%d %H:%M:%S"), line)) def error(message): if log_level >= LOG_LEVEL_ERROR: From 4ce3ef04057edbe7722af7e70abdea5075765aa3 Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Sat, 13 Mar 2021 21:43:40 +0100 Subject: [PATCH 2/3] docs: v1.3.3 --- CHANGELOG.md | 4 ++-- Makefile | 2 +- README.md | 16 ++++++++-------- example/multiple-process-image/Dockerfile | 2 +- example/single-process-image/Dockerfile | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57c4d3b2..ae3e3e60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -# [1.4.0] - Unreleased +# [1.3.3] - Unreleased ### Changed - Multiple log line message are now split and log line by line for a nicest display. @@ -176,7 +176,7 @@ ## 0.1.0 - 2015-07-23 Initial release -[1.4.0]: https://github.com/osixia/docker-light-baseimage/compare/v1.3.2...v1.4.0 +[1.3.3]: https://github.com/osixia/docker-light-baseimage/compare/v1.3.2...v1.3.3 [1.3.2]: https://github.com/osixia/docker-light-baseimage/compare/v1.3.1...v1.3.2 [1.3.1]: https://github.com/osixia/docker-light-baseimage/compare/v1.3.0...v1.3.1 [1.3.0]: https://github.com/osixia/docker-light-baseimage/compare/v1.2.0...v1.3.0 diff --git a/Makefile b/Makefile index 7f55fa5f..ddf4f672 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ NAME = osixia/light-baseimage -VERSION = 1.3.2 +VERSION = 1.3.3 .PHONY: build build-nocache test tag-latest push push-latest release git-tag-version diff --git a/README.md b/README.md index 71e39cb7..afaebf3b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [hub]: https://hub.docker.com/r/osixia/light-baseimage/ -Latest release: 1.3.2 [Changelog](CHANGELOG.md) +Latest release: 1.3.3 [Changelog](CHANGELOG.md) | [Docker Hub](https://hub.docker.com/r/osixia/light-baseimage/)  A **Debian 10 (Buster)** based docker image to build reliable image quickly. This image provide a simple opinionated solution to build multiple or single process image with minimum of layers and an optimized build. @@ -150,7 +150,7 @@ In the Dockerfile we are going to: # Use osixia/light-baseimage # https://github.com/osixia/docker-light-baseimage - FROM osixia/light-baseimage:1.3.2 + FROM osixia/light-baseimage:1.3.3 # Download nginx from apt-get and clean apt-get files RUN apt-get -y update \ @@ -392,7 +392,7 @@ In the Dockerfile we are going to: # Use osixia/light-baseimage # https://github.com/osixia/docker-light-baseimage - FROM osixia/light-baseimage:1.3.2 + FROM osixia/light-baseimage:1.3.3 # Install multiple process stack, nginx and php7.0-fpm and clean apt-get files # https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/add-multiple-process-stack @@ -593,7 +593,7 @@ Here simple Dockerfile example how to add a service-available to an image: # Use osixia/light-baseimage # https://github.com/osixia/docker-light-baseimage - FROM osixia/light-baseimage:1.3.2 + FROM osixia/light-baseimage:1.3.3 # Add cfssl and cron service-available # https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/add-service-available @@ -662,7 +662,7 @@ What it does: *Run tool* takes several options, to list them: - docker run osixia/light-baseimage:1.3.2 --help + docker run osixia/light-baseimage:1.3.3 --help usage: run [-h] [-e] [-s] [-p] [-f] [-o {startup,process,finish}] [-c COMMAND [WHEN={startup,process,finish} ...]] [-k] [--wait-state FILENAME] [--wait-first-startup] [--keep-startup-env] @@ -773,7 +773,7 @@ If a main command is set for example: If a main command is set *run tool* launch it otherwise bash is launched. Example: - docker run -it osixia/light-baseimage:1.3.2 + docker run -it osixia/light-baseimage:1.3.3 ##### Extra environment variables @@ -849,8 +849,8 @@ Note this yaml definition: Can also be set by command line converted in python or json: - docker run -it --env FRUITS="#PYTHON2BASH:['orange','apple']" osixia/light-baseimage:1.3.2 printenv - docker run -it --env FRUITS="#JSON2BASH:[\"orange\",\"apple\"]" osixia/light-baseimage:1.3.2 printenv + docker run -it --env FRUITS="#PYTHON2BASH:['orange','apple']" osixia/light-baseimage:1.3.3 printenv + docker run -it --env FRUITS="#JSON2BASH:[\"orange\",\"apple\"]" osixia/light-baseimage:1.3.3 printenv ### Tests diff --git a/example/multiple-process-image/Dockerfile b/example/multiple-process-image/Dockerfile index 458a386e..17e3e23c 100644 --- a/example/multiple-process-image/Dockerfile +++ b/example/multiple-process-image/Dockerfile @@ -1,6 +1,6 @@ # Use osixia/light-baseimage # https://github.com/osixia/docker-light-baseimage -FROM osixia/light-baseimage:1.3.2 +FROM osixia/light-baseimage:1.3.3 # Install multiple process stack, nginx and php7.0-fpm and clean apt-get files # https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/add-multiple-process-stack diff --git a/example/single-process-image/Dockerfile b/example/single-process-image/Dockerfile index 48a193e2..069efc3a 100644 --- a/example/single-process-image/Dockerfile +++ b/example/single-process-image/Dockerfile @@ -1,6 +1,6 @@ # Use osixia/light-baseimage # https://github.com/osixia/docker-light-baseimage -FROM osixia/light-baseimage:1.3.2 +FROM osixia/light-baseimage:1.3.3 # Download nginx from apt-get and clean apt-get files RUN apt-get -y update \ From 64faa55ebddcfb713b154ae108d2331858840fb7 Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Sat, 13 Mar 2021 21:53:12 +0100 Subject: [PATCH 3/3] fix: log-level broken pipe --- CHANGELOG.md | 3 +++ image/tool/log-helper | 25 ++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae3e3e60..d7ede333 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ ### Changed - Multiple log line message are now split and log line by line for a nicest display. +### Fixed +- log-level broken pipe + # [1.3.2] - 2021-02-18 ### Fixed - Remove -x bash flag on log-helper tool diff --git a/image/tool/log-helper b/image/tool/log-helper index f8bc6036..61a52ea8 100755 --- a/image/tool/log-helper +++ b/image/tool/log-helper @@ -42,36 +42,51 @@ function print_log(){ } function error() { + + # getEchoParams no matter what level it is to not break pipes + getEchoParams $@ + if [ $log_level -ge 1 ]; then - getEchoParams $@ echo $echo_param "$(print_log " ERROR " "$echo_msg")" fi } function warning() { + + # getEchoParams no matter what level it is to not break pipes + getEchoParams $@ + if [ $log_level -ge 2 ]; then - getEchoParams $@ echo $echo_param "$(print_log "WARNING" "$echo_msg")" fi } function info() { + + # getEchoParams no matter what level it is to not break pipes + getEchoParams $@ + if [ $log_level -ge 3 ]; then - getEchoParams $@ echo $echo_param "$(print_log " INFO " "$echo_msg")" fi } function debug() { + + # getEchoParams no matter what level it is to not break pipes + getEchoParams $@ + if [ $log_level -ge 4 ]; then - getEchoParams $@ echo $echo_param "$(print_log " DEBUG " "$echo_msg")" fi } function trace() { + + # getEchoParams no matter what level it is to not break pipes + getEchoParams $@ + if [ $log_level -ge 5 ]; then - getEchoParams $@ echo $echo_param "$(print_log " TRACE " "$echo_msg")" fi }