From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6563125043888390144 X-Received: by 2002:aa7:c1d3:: with SMTP id d19-v6mr654910edp.6.1528191238747; Tue, 05 Jun 2018 02:33:58 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a50:c441:: with SMTP id w1-v6ls27206911edf.1.gmail; Tue, 05 Jun 2018 02:33:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL3DlDJHtVpBpa+a/8QxmzKa4JsYCA77mXjaggBtBfUiQ9swRGlgWA8nGAteEJzOGEUY17b X-Received: by 2002:aa7:c659:: with SMTP id z25-v6mr652221edr.5.1528191238178; Tue, 05 Jun 2018 02:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528191238; cv=none; d=google.com; s=arc-20160816; b=bG8QGX2frMELED4oU7ZZJqOmRCDJEiyOxTYfWt7lqT5YWtIKuH3pLNB8ORb4yP0+jp uf0L/Z/atObhoCBc8dxE3ih52atp/97rTNVfStSpmfXP6LlaV89NpzGCPemq3wW9YQkI E3X5dRaOs9HMTPCo3vKjI7G0YWsHlZqqEgv9H6V7q5P4+TKZaqX6WKyXpp42fBUlkV1B F59Osg+95InwGUuXMUE/qfHCYj23T2TKykC1wDpQSKZbXN9OyfXRVAdjyma9R96/30Dn BT5fzbsJwUzN8nnr7+2U0nOUaKdIyce0DChcF8fG2X/wYgaDPakQTin0egfB2MNUAj38 8GIA== 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:autocrypt:openpgp:from:references:to :subject:arc-authentication-results; bh=hQWgHFe9IOxLFucASnL+gy4LQQxzqI0J00QfbLILgRg=; b=ZPbGN23Ye7Br2Kwge3ZQI5/SG3sHvyRdFj202/DkAF2hbYlssvZ4Vk/SaYzcazT7lA NLsFgVG4FbnJbHp0h/g1vMP3ZPm+kDSZwofzhwG2nRRI6RcN+52TARqVv0GLW20cwOnj QScteVwuF8lsVBCV7CgcD9918gdRxDYnWBQMOZTrsq8nysd+wlZddmLVqSAzpg4MFrUz S/0r9pq0isuozjtJz+A9vT0d9IVSQ9orRbq2H8rlDL38n47Lm5UpeB3UTKgxGVnHF3Zk Jv4BvEsNf2vbbdf8py0Y9UBWNiGgQBr4h/v5QriP3osNHh0oAsLuAs7TOnEHbZxLLEu3 jedg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Return-Path: Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id u7-v6si127262edo.2.2018.06.05.02.33.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 02:33:58 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w559XvqQ031907 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 Jun 2018 11:33:57 +0200 Received: from [167.87.50.224] ([167.87.50.224]) by mail2.siemens.de (8.15.2/8.15.2) with ESMTP id w559Xux3012766; Tue, 5 Jun 2018 11:33:57 +0200 Subject: Re: [PATCH] Import OE-core logger To: "Maxim Yu. Osipov" , isar-users References: <562383dd-072b-9d5d-e486-5eb6558d5e0f@siemens.com> From: Jan Kiszka Openpgp: preference=signencrypt Autocrypt: addr=jan.kiszka@siemens.com; prefer-encrypt=mutual; keydata= xsDhBEq0i8QRBAD2wOxlC9m/8t/vqjm1U9yQCT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YrEslPWiCA2wU6EW0yaqBQAobFsOMvsufJ6o2ntq5Ncq37VI 3KCT67eHPE9x+zPcENoZWsRrC9S9PCf1LOsi7ybZsR13AJqDFlRzJZ4klh9QwgwFZxUBzOdI vttwzG1QkzHx06RKZluFYpPF3DRduSMukdIJ2wmWCU+ohB+mYefe65JGjYQfHVs8mgYVFOPx bRea9VJACCMuspoZWpj43UdR1lLLyIUFYz+jqcPW7Hd/GTIw4N67pYl0dwPDmFd4ohJ5g4Zp q61toNysBGEuEm5GCcn0VmGtQpSYnR5cVm5b2yPz4bIuFOSuZUo/l7vitdY0iy0/wvKbBC+N K8JJBBgRAgAJBQJKtIvEAhsMAAoJEIrUrG965ecULvAAoKGvxs5T3IhyQT8I8sMsyAvCE4wH AJ46S16yab+OxNkvOeoOEX0EnHVHaA== Message-ID: <7df8fbe1-4882-83f6-bd73-63481eea1b60@siemens.com> Date: Tue, 5 Jun 2018 11:33:56 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-TUID: GZUWpPZYf3le On 2018-06-05 11:24, Maxim Yu. Osipov wrote: > 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, > This was a 1:1 import from OE. Now it's only (hopefully) logically identical. Jan > 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 >> +} >> > > -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux