From ecc68fa4fbb579e97ea45156e79a293b073697a0 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 10 Jun 2010 10:35:31 -0700 Subject: Switch bitbake internals to use logging directly rather than bb.msg We use a custom Logger subclass for our loggers This logger provides: - 'debug' method which accepts a debug level - 'plain' method which bypasses log formatting - 'verbose' method which is more detail than info, but less than debug (Bitbake rev: 3b2c1fe5ca56daebb24073a9dd45723d3efd2a8d) Signed-off-by: Chris Larson Signed-off-by: Richard Purdie --- bitbake/lib/bb/parse/__init__.py | 9 +++++++-- bitbake/lib/bb/parse/ast.py | 12 ++++++++---- bitbake/lib/bb/parse/parse_py/BBHandler.py | 9 +++++---- bitbake/lib/bb/parse/parse_py/ConfHandler.py | 5 +++-- 4 files changed, 23 insertions(+), 12 deletions(-) (limited to 'bitbake/lib/bb/parse') diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py index da160ceb2..f9517f03f 100644 --- a/bitbake/lib/bb/parse/__init__.py +++ b/bitbake/lib/bb/parse/__init__.py @@ -26,9 +26,14 @@ File parsers for the BitBake build tools. handlers = [] -import bb, os +import os +import logging +import bb import bb.utils import bb.siggen +import bb.utils + +logger = logging.getLogger("BitBake.Parsing") class ParseError(Exception): """Exception raised when parsing fails""" @@ -91,7 +96,7 @@ def resolve_file(fn, d): raise IOError("file %s not found in %s" % (fn, bbpath)) fn = newfn - bb.msg.debug(2, bb.msg.domain.Parsing, "LOAD %s" % fn) + logger.debug(2, "LOAD %s", fn) return fn # Used by OpenEmbedded metadata diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 870ae65b0..55ab48599 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py @@ -23,9 +23,13 @@ from __future__ import absolute_import from future_builtins import filter -import bb, re, string -from bb import methodpool +import re +import string +import logging +import bb import itertools +from bb import methodpool +from bb.parse import logger __word__ = re.compile(r"\S+") __parsed_methods__ = bb.methodpool.get_parsed_dict() @@ -51,7 +55,7 @@ class IncludeNode(AstNode): Include the file and evaluate the statements """ s = bb.data.expand(self.what_file, data) - bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (self.from_fn, self.from_lineno, s)) + logger.debug(2, "CONF %s:%s: including %s", self.from_fn, self.from_lineno, s) # TODO: Cache those includes... maybe not here though if self.force: @@ -365,7 +369,7 @@ def _expand_versions(versions): def multi_finalize(fn, d): appends = (d.getVar("__BBAPPEND", True) or "").split() for append in appends: - bb.msg.debug(2, bb.msg.domain.Parsing, "Appending .bbappend file " + append + " to " + fn) + logger.debug(2, "Appending .bbappend file %s to %s", append, fn) bb.parse.BBHandler.handle(append, d, True) safe_d = d diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 51ad10fb9..31f44f7df 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py @@ -27,11 +27,12 @@ from __future__ import absolute_import import re, bb, os +import logging import bb.fetch, bb.build, bb.utils from bb import data from . import ConfHandler -from .. import resolve_file, ast +from .. import resolve_file, ast, logger from .ConfHandler import include, init # For compatibility @@ -76,7 +77,7 @@ def inherit(files, d): file = os.path.join('classes', '%s.bbclass' % file) if not file in __inherit_cache: - bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file)) + logger.log(logging.DEBUG -1, "BB %s:%d: inheriting %s", fn, lineno, file) __inherit_cache.append( file ) data.setVar('__inherit_cache', __inherit_cache, d) include(fn, file, d, "inherit") @@ -115,9 +116,9 @@ def handle(fn, d, include): if include == 0: - bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data)") + logger.debug(2, "BB %s: handle(data)", fn) else: - bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data, include)") + logger.debug(2, "BB %s: handle(data, include)", fn) (root, ext) = os.path.splitext(os.path.basename(fn)) base_name = "%s%s" % (root, ext) diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 9128a2ef8..2abd2fdc2 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py @@ -25,8 +25,9 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import re, bb.data, os +import logging import bb.utils -from bb.parse import ParseError, resolve_file, ast +from bb.parse import ParseError, resolve_file, ast, logger #__config_regexp__ = re.compile( r"(?Pexport\s*)?(?P[a-zA-Z0-9\-_+.${}]+)\s*(?P:)?(?P\?)?=\s*(?P['\"]?)(?P.*)(?P=apo)$") __config_regexp__ = re.compile( r"(?Pexport\s*)?(?P[a-zA-Z0-9\-_+.${}/]+)(\[(?P[a-zA-Z0-9\-_+.]+)\])?\s*((?P:=)|(?P\?\?=)|(?P\?=)|(?P\+=)|(?P=\+)|(?P=\.)|(?P\.=)|=)\s*(?P['\"]?)(?P.*)(?P=apo)$") @@ -68,7 +69,7 @@ def include(oldfn, fn, data, error_out): except IOError: if error_out: raise ParseError("Could not %(error_out)s file %(fn)s" % vars() ) - bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn) + logger.debug(2, "CONF file '%s' not found", fn) def handle(fn, data, include): init(data) -- cgit v1.2.3