From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: bitbake-devel <bitbake-devel@lists.openembedded.org>
Subject: [PATCH] bitbake/msg.py: Drop manually created domain lists
Date: Fri, 12 Aug 2011 15:25:58 +0100 [thread overview]
Message-ID: <1313159158.14274.491.camel@rex> (raw)
This patch removes the majority of the domain related code from bb.msg
on the grounds that we now support dynamic creation of logging domains
so having this hardcoded is just error prone and less flexible. It also
makes the msg code overly and needlessly complex.
It also removes the bb.msg.debug/note/warn/plain/error functions since
we might as well remove them rather than try and fix them at this point.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index a3f8795..19b9045 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/lib/bb/msg.py
@@ -94,35 +94,6 @@ class BBLogFilter(object):
return False
-class Loggers(dict):
- def __getitem__(self, key):
- if key in self:
- return dict.__getitem__(self, key)
- else:
- log = logging.getLogger("BitBake.%s" % domain._fields[key])
- dict.__setitem__(self, key, log)
- return log
-
-def _NamedTuple(name, fields):
- Tuple = collections.namedtuple(name, " ".join(fields))
- return Tuple(*range(len(fields)))
-
-domain = _NamedTuple("Domain", (
- "Default",
- "Build",
- "Cache",
- "Collection",
- "Data",
- "Depends",
- "Fetcher",
- "Parsing",
- "PersistData",
- "Provider",
- "RunQueue",
- "TaskData",
- "Util"))
-logger = logging.getLogger("BitBake")
-loggers = Loggers()
# Message control functions
#
@@ -152,11 +123,6 @@ def addDefaultlogFilter(handler):
for (domainarg, iterator) in groupby(domains):
dlevel = len(tuple(iterator))
debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1
- for index, msgdomain in enumerate(domain._fields):
- if msgdomain == domainarg:
- break
- else:
- warn(None, "Logging domain %s is not valid, ignoring" % domainarg)
BBLogFilter(handler, level, debug_domains)
@@ -164,53 +130,10 @@ def addDefaultlogFilter(handler):
# Message handling functions
#
-def debug(level, msgdomain, msg):
- warnings.warn("bb.msg.debug is deprecated in favor of the python 'logging' module",
- DeprecationWarning, stacklevel=2)
- level = logging.DEBUG - (level - 1)
- if not msgdomain:
- logger.debug(level, msg)
- else:
- loggers[msgdomain].debug(level, msg)
-
-def plain(msg):
- warnings.warn("bb.msg.plain is deprecated in favor of the python 'logging' module",
- DeprecationWarning, stacklevel=2)
- logger.plain(msg)
-
-def note(level, msgdomain, msg):
- warnings.warn("bb.msg.note is deprecated in favor of the python 'logging' module",
- DeprecationWarning, stacklevel=2)
- if level > 1:
- if msgdomain:
- logger.verbose(msg)
- else:
- loggers[msgdomain].verbose(msg)
- else:
- if msgdomain:
- logger.info(msg)
- else:
- loggers[msgdomain].info(msg)
-
-def warn(msgdomain, msg):
- warnings.warn("bb.msg.warn is deprecated in favor of the python 'logging' module",
- DeprecationWarning, stacklevel=2)
- if not msgdomain:
- logger.warn(msg)
- else:
- loggers[msgdomain].warn(msg)
-
-def error(msgdomain, msg):
- warnings.warn("bb.msg.error is deprecated in favor of the python 'logging' module",
- DeprecationWarning, stacklevel=2)
- if not msgdomain:
- logger.error(msg)
- else:
- loggers[msgdomain].error(msg)
-
def fatal(msgdomain, msg):
- if not msgdomain:
- logger.critical(msg)
+ if msgdomain:
+ logger = logging.getLogger("BitBake.%s" % msgdomin)
else:
- loggers[msgdomain].critical(msg)
+ logger = logging.getLogger("BitBake")
+ logger.critical(msg)
sys.exit(1)
reply other threads:[~2011-08-12 14:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1313159158.14274.491.camel@rex \
--to=richard.purdie@linuxfoundation.org \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox