From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6563125043888390144 X-Received: by 2002:a2e:9e4c:: with SMTP id g12-v6mr1368700ljk.37.1528190664345; Tue, 05 Jun 2018 02:24:24 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a2e:4488:: with SMTP id b8-v6ls5723291ljf.12.gmail; Tue, 05 Jun 2018 02:24:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIOnhhn0hUpeyTAU2/MheHDV98ezRrSS7mV8BzaU9lYGJjWYxwQn235eRQeERk9LSdHphPq X-Received: by 2002:a2e:9c09:: with SMTP id s9-v6mr1386725lji.20.1528190663842; Tue, 05 Jun 2018 02:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528190663; cv=none; d=google.com; s=arc-20160816; b=IspVIVG4/Gus2Tz3KwuRurdDU3gev4TK/hDhcr/ZOwQrMTngWSBQ39XEwPnvR2Kd8F Nqb/QqFcdRLzbysAAPL5ss4m4yWjiqN0Nps4wAWe4CY3qZg/3/0t27eI+N8vD3UOwvb0 J+Pq7ASsYgBwCs0xsnTHp9lS5qnNLGQP3KQYCUMOs/raS+Ya/Bwb4DYyx4kcduZTK2M7 yRqE2pdMYfgfRMpvq7Y5gaEmPu+WxpBeQoAvHE8VOnOvLX9IxUlZY++/q0hi2CFv3CQd nTzYf/Aregt4vCy1LKN/NlTaNTdTlolvW1oebiGoBavCUuhZoupa/B42UzGDPgrDWg2v OwrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:organization:from:references:to:subject :arc-authentication-results; bh=qcGIeumUqHteuYOb2zQHQWnzt2AR9JEEkNbBZbZJW80=; b=wAHjKlBJTLychsMCq9yghywbXo4WAG36MGoKU69n9WgZFlHR3+UJQuJqWHlY182tQD kUCpGvP6f4ADPUvdAG1V9H1EbrVLC0pAaXvFXbizVvxucmaQBy2nRy9+QPktrrEm03EO TPPjp2Kh4Hd1fRh4EuUnif/7n/5NVwsYtlawREdvvxte4iSUv64DVjIKwETLR33195M7 k5h64/FUMueozzhtK4zxGybGByKoWu1jIeu10I/RlQIuAi/28EnMAB+TzbR2pMhzx3FN RjaKTESyvUYb6iAgBw25ayrhWyiJhOmBXRmDSdTTknpwr000tDhr6y3sgGLxu5wFAbD8 yMdg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id b17-v6si1697362lfa.2.2018.06.05.02.24.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 02:24:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Received: from [192.168.50.163] (d51A48A80.access.telenet.be [81.164.138.128]) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id w559OJmM031992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Tue, 5 Jun 2018 11:24:20 +0200 Subject: Re: [PATCH] Import OE-core logger To: Jan Kiszka , isar-users References: <562383dd-072b-9d5d-e486-5eb6558d5e0f@siemens.com> From: "Maxim Yu. Osipov" Organization: ilbers GmbH Message-ID: Date: Tue, 5 Jun 2018 11:24:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <562383dd-072b-9d5d-e486-5eb6558d5e0f@siemens.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: /i1s6Mer/ztr On 06/04/2018 09:17 AM, Jan Kiszka wrote: > From: Jan Kiszka > > This ensures bash recipe messages go to the logger, not just the recipe > log files. It also adds the missing bbplain, bberror and bbdebug > functions. Fixed a couple of trailing whitespaces and applied to next, Thanks, Maxim. > Signed-off-by: Jan Kiszka > --- > meta/classes/base.bbclass | 13 +----- > meta/classes/logging.bbclass | 105 +++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 106 insertions(+), 12 deletions(-) > create mode 100644 meta/classes/logging.bbclass > > diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass > index d1df8cc3..99730e59 100644 > --- a/meta/classes/base.bbclass > +++ b/meta/classes/base.bbclass > @@ -24,18 +24,7 @@ die() { > bbfatal "$*" > } > > -bbnote() { > - echo "NOTE:" "$*" > -} > - > -bbwarn() { > - echo "WARNING:" "$*" > -} > - > -bbfatal() { > - echo "FATAL:" "$*" > - exit 1 > -} > +inherit logging > > # Derived from bitbake: bitbake/classes/base.bbclass > addtask showdata > diff --git a/meta/classes/logging.bbclass b/meta/classes/logging.bbclass > new file mode 100644 > index 00000000..3277aa34 > --- /dev/null > +++ b/meta/classes/logging.bbclass > @@ -0,0 +1,105 @@ > +# > +# Imported from OE-core project > +# > +# SPDX-License-Identifier: MIT > + > +# The following logging mechanisms are to be used in bash functions of recipes. > +# They are intended to map one to one in intention and output format with the > +# python recipe logging functions of a similar naming convention: bb.plain(), > +# bb.note(), etc. > + > +LOGFIFO = "${T}/fifo.${@os.getpid()}" > + > +# Print the output exactly as it is passed in. Typically used for output of > +# tasks that should be seen on the console. Use sparingly. > +# Output: logs console > +bbplain() { > + if [ -p ${LOGFIFO} ] ; then > + printf "%b\0" "bbplain $*" > ${LOGFIFO} > + else > + echo "$*" > + fi > +} > + > +# Notify the user of a noteworthy condition. > +# Output: logs > +bbnote() { > + if [ -p ${LOGFIFO} ] ; then > + printf "%b\0" "bbnote $*" > ${LOGFIFO} > + else > + echo "NOTE: $*" > + fi > +} > + > +# Print a warning to the log. Warnings are non-fatal, and do not > +# indicate a build failure. > +# Output: logs console > +bbwarn() { > + if [ -p ${LOGFIFO} ] ; then > + printf "%b\0" "bbwarn $*" > ${LOGFIFO} > + else > + echo "WARNING: $*" > + fi > +} > + > +# Print an error to the log. Errors are non-fatal in that the build can > +# continue, but they do indicate a build failure. > +# Output: logs console > +bberror() { > + if [ -p ${LOGFIFO} ] ; then > + printf "%b\0" "bberror $*" > ${LOGFIFO} > + else > + echo "ERROR: $*" > + fi > +} > + > +# Print a fatal error to the log. Fatal errors indicate build failure > +# and halt the build, exiting with an error code. > +# Output: logs console > +bbfatal() { > + if [ -p ${LOGFIFO} ] ; then > + printf "%b\0" "bbfatal $*" > ${LOGFIFO} > + else > + echo "ERROR: $*" > + fi > + exit 1 > +} > + > +# Like bbfatal, except prevents the suppression of the error log by > +# bitbake's UI. > +# Output: logs console > +bbfatal_log() { > + if [ -p ${LOGFIFO} ] ; then > + printf "%b\0" "bbfatal_log $*" > ${LOGFIFO} > + else > + echo "ERROR: $*" > + fi > + exit 1 > +} > + > +# Print debug messages. These are appropriate for progress checkpoint > +# messages to the logs. Depending on the debug log level, they may also > +# go to the console. > +# Output: logs console > +# Usage: bbdebug 1 "first level debug message" > +# bbdebug 2 "second level debug message" > +bbdebug() { > + USAGE='Usage: bbdebug [123] "message"' > + if [ $# -lt 2 ]; then > + bbfatal "$USAGE" > + fi > + > + # Strip off the debug level and ensure it is an integer > + DBGLVL=$1; shift > + NONDIGITS=$(echo "$DBGLVL" | tr -d [:digit:]) > + if [ "$NONDIGITS" ]; then > + bbfatal "$USAGE" > + fi > + > + # All debug output is printed to the logs > + if [ -p ${LOGFIFO} ] ; then > + printf "%b\0" "bbdebug $DBGLVL $*" > ${LOGFIFO} > + else > + echo "DEBUG: $*" > + fi > +} > -- Maxim Osipov ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn Germany +49 (151) 6517 6917 mosipov@ilbers.de http://ilbers.de/ Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov