From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6563125043888390144 X-Received: by 2002:a19:18a2:: with SMTP id 34-v6mr790305lfy.0.1528096628142; Mon, 04 Jun 2018 00:17:08 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a2e:4488:: with SMTP id b8-v6ls5321185ljf.12.gmail; Mon, 04 Jun 2018 00:17:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ/ChcNcUJSTEKVJIzxGwSSQo55hmpYp7wt/vy2NMAdN5RJiAW0fbPnWVpFca3bjFBfkgEF X-Received: by 2002:a2e:94c7:: with SMTP id r7-v6mr1070441ljh.11.1528096627535; Mon, 04 Jun 2018 00:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528096627; cv=none; d=google.com; s=arc-20160816; b=sg8f1rBphUx3b7DZmsGVpmQFNlUDeJmzOxOZm4k88UF9Rcg9aEDda6exzw8PG7Hyv0 oX3CrQU5y/cSR5Wl9RZnnQMqX/FkPctVFFEzGEi53BPUrwUETVn6aDCxxmmD0Cc+uRx5 UIUB6dybkT6UOFwjjJBmfqbiDY1JfbuFpw/X7Pn+ekOtAYJ0lAaLH+doACMOdpFB59g6 POJH4LYL7oJbCt3vnOvrBN5dlQxESVsu0OvN4RKzz7c/8u25hk9aheWc5GPTUSWO1RE9 JaXO6+37lQZ/Cghg1jKdZl1SakKaTMzjorIl5q0zSQdiGtkAN2tGkHwBzXFAWarWa5wk hWFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version:user-agent :date:message-id:autocrypt:openpgp:subject:from:to :arc-authentication-results; bh=8/1q7oEYdME6oSNJb9HPaxrcjyapJhyfxqMIfJxEj/E=; b=Ihcfb4yPtrMplj5vgpjX7Pl3JoxVRJyg0JpfzSNYNo0QhtuJDsRV0rih48Gdco6+Jj wscIKtXRctDJYdCj1pnPjwEPqSdtHc8tZ5X5g7YxqyaC1VDRY5akFACce9fRYv3qxCcS iEkrjEIW+hiyTjlf50U89uQdhPR3ZS4Qw0VmYj+vHDszRcjXALXxJvmdeQzLw+xL9n81 UauVKjlqiWeMIAhyKlO8cgBGyzw59l2c1+bhHCi9r5FpoyMnvq+TCyxo19MKMyxwDzFC 0Oq/dc+VAF8LCv7X2vLgYNDsz2QRkwSootlC/s/aqMA+/xKYxY4GAVT8N0HJaX03QADR 2NGw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Return-Path: Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id j127-v6si1771803lfe.4.2018.06.04.00.17.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 00:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w547H6f5017699 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 4 Jun 2018 09:17:06 +0200 Received: from [139.22.116.229] ([139.22.116.229]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w547H6SR017047 for ; Mon, 4 Jun 2018 09:17:06 +0200 X-Mozilla-News-Host: news://news.gmane.org:119 To: isar-users From: Jan Kiszka Subject: [PATCH] Import OE-core logger Openpgp: preference=signencrypt Autocrypt: addr=jan.kiszka@siemens.com; prefer-encrypt=mutual; keydata= xsDhBEq0i8QRBAD2wOxlC9m/8t/vqjm1U9yQCT6OJ2Wbv/qys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6EW0yaqBQAobFsOMvsufJ6o2ntq5Ncq37VI 3KCT67eHPE9x+zPcENoZWsRrC9S9PCf1LOsi7ybZsR13AJqDFlRzJZ4klh9QwgwFZxUBzOdI vttwzG1QkzHx06RKZluFYpPF3DRduSMukdIJ2wmWCU+ohB+mYefe65JGjYQfHVs8mgYVFOPx bRea9VJACCMuspoZWpj43UdR1lLLyIUFYz+jqcPW7Hd/GTIw4N67pYl0dwPDmFd4ohJ5g4Zp q61toNysBGEuEm5GCcn0VmGtQpSYnR5cVm5b2yPz4bIuFOSuZUo/l7vitdY0iy0/wvKbBC+N K8JJBBgRAgAJBQJKtIvEAhsMAAoJEIrUrG965ecULvAAoKGvxs5T3IhyQT8I8sMsyAvCE4wH AJ46S16yab+OxNkvOeoOEX0EnHVHaA== Message-ID: <562383dd-072b-9d5d-e486-5eb6558d5e0f@siemens.com> Date: Mon, 4 Jun 2018 09:17:06 +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 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: FICEY2B392AZ 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. 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 +} -- 2.13.6