diff options
author | Richard Purdie <richard@openedhand.com> | 2006-11-16 15:02:15 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2006-11-16 15:02:15 +0000 |
commit | 306b7c7a9757ead077363074e7bbac2e5c03e7c5 (patch) | |
tree | 6935017a9af749c46816881c86258f514384ba1c /bitbake/lib/bb/msg.py | |
parent | 65930a38e415ae4a0182e1cea1be838e0ada50ee (diff) | |
download | poky-306b7c7a9757ead077363074e7bbac2e5c03e7c5.tar.gz |
bitbake: Upgrade from 1.4 -> 1.7.4ish
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@863 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake/lib/bb/msg.py')
-rw-r--r-- | bitbake/lib/bb/msg.py | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py new file mode 100644 index 0000000000..473851cc72 --- /dev/null +++ b/bitbake/lib/bb/msg.py | |||
@@ -0,0 +1,108 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # ex:ts=4:sw=4:sts=4:et | ||
3 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
4 | """ | ||
5 | BitBake 'msg' implementation | ||
6 | |||
7 | Message handling infrastructure for bitbake | ||
8 | |||
9 | # Copyright (C) 2006 Richard Purdie | ||
10 | |||
11 | This program is free software; you can redistribute it and/or modify it under | ||
12 | the terms of the GNU General Public License as published by the Free Software | ||
13 | Foundation; either version 2 of the License, or (at your option) any later | ||
14 | version. | ||
15 | |||
16 | This program is distributed in the hope that it will be useful, but WITHOUT | ||
17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
18 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU General Public License along with | ||
21 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
22 | Place, Suite 330, Boston, MA 02111-1307 USA. | ||
23 | |||
24 | """ | ||
25 | |||
26 | import sys, os, re, bb | ||
27 | from bb import utils | ||
28 | |||
29 | debug_level = {} | ||
30 | |||
31 | verbose = False | ||
32 | |||
33 | domain = bb.utils.Enum( | ||
34 | 'Build', | ||
35 | 'Cache', | ||
36 | 'Collection', | ||
37 | 'Data', | ||
38 | 'Depends', | ||
39 | 'Fetcher', | ||
40 | 'Parsing', | ||
41 | 'Provider', | ||
42 | 'RunQueue', | ||
43 | 'TaskData', | ||
44 | 'Util') | ||
45 | |||
46 | # | ||
47 | # Message control functions | ||
48 | # | ||
49 | |||
50 | def set_debug_level(level): | ||
51 | bb.msg.debug_level = {} | ||
52 | for domain in bb.msg.domain: | ||
53 | bb.msg.debug_level[domain] = level | ||
54 | bb.msg.debug_level['default'] = level | ||
55 | |||
56 | def set_verbose(level): | ||
57 | bb.msg.verbose = level | ||
58 | |||
59 | def set_debug_domains(domains): | ||
60 | for domain in domains: | ||
61 | found = False | ||
62 | for ddomain in bb.msg.domain: | ||
63 | if domain == str(ddomain): | ||
64 | bb.msg.debug_level[ddomain] = bb.msg.debug_level[ddomain] + 1 | ||
65 | found = True | ||
66 | if not found: | ||
67 | std_warn("Logging domain %s is not valid, ignoring" % domain) | ||
68 | |||
69 | # | ||
70 | # Message handling functions | ||
71 | # | ||
72 | |||
73 | def debug(level, domain, msg, fn = None): | ||
74 | if debug_level[domain] >= level: | ||
75 | print 'DEBUG: ' + msg | ||
76 | |||
77 | def note(level, domain, msg, fn = None): | ||
78 | if level == 1 or verbose or debug_level[domain] >= 1: | ||
79 | std_note(msg) | ||
80 | |||
81 | def warn(domain, msg, fn = None): | ||
82 | std_warn(msg) | ||
83 | |||
84 | def error(domain, msg, fn = None): | ||
85 | std_error(msg) | ||
86 | |||
87 | def fatal(domain, msg, fn = None): | ||
88 | std_fatal(msg) | ||
89 | |||
90 | # | ||
91 | # Compatibility functions for the original message interface | ||
92 | # | ||
93 | def std_debug(lvl, msg): | ||
94 | if debug_level['default'] >= lvl: | ||
95 | print 'DEBUG: ' + msg | ||
96 | |||
97 | def std_note(msg): | ||
98 | print 'NOTE: ' + msg | ||
99 | |||
100 | def std_warn(msg): | ||
101 | print 'WARNING: ' + msg | ||
102 | |||
103 | def std_error(msg): | ||
104 | print 'ERROR: ' + msg | ||
105 | |||
106 | def std_fatal(msg): | ||
107 | print 'ERROR: ' + msg | ||
108 | sys.exit(1) | ||