Merge lp:~tony-badwolf/quickly/quicklyloggingupdate into lp:quickly

Proposed by Tony Byrne
Status: Needs review
Proposed branch: lp:~tony-badwolf/quickly/quicklyloggingupdate
Merge into: lp:quickly
Diff against target: 145 lines (+42/-17)
7 files modified
data/templates/ubuntu-application/create.py (+1/-1)
data/templates/ubuntu-application/project_root/python/__init__.py (+16/-3)
data/templates/ubuntu-application/project_root/python_lib/Builder.py (+1/-1)
data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py (+1/-1)
data/templates/ubuntu-application/project_root/python_lib/Window.py (+1/-1)
data/templates/ubuntu-application/project_root/python_lib/helpers.py (+8/-10)
data/templates/ubuntu-application/run.py (+14/-0)
To merge this branch: bzr merge lp:~tony-badwolf/quickly/quicklyloggingupdate
Reviewer Review Type Date Requested Status
Quickly Developers Pending
Review via email: mp+84413@code.launchpad.net

Description of the change

documents logging usage within code comments
restores original logging command line usage -d debug
all modules use same logger because some lib modules report on glade signals and preferences mismatches
default to logging level debug while project runs within quickly

To post a comment you must log in.

Unmerged revisions

643. By Tony Byrne <email address hidden> <email address hidden>

A more sensible default
Turn on logging while project runs inside quickly

642. By Tony Byrne <email address hidden> <email address hidden>

restores original "API" for logging
default logging.ERROR
-v logging.WARNING
-vv logging.INFO
-vvv logging.DEBUG
-d logging.DEBUG
fixes https://bugs.launchpad.net/quickly/+bug/882842

documents logging usage in __init__.py
addresses https://answers.launchpad.net/quickly/+question/176340

641. By Tony Byrne <email address hidden> <email address hidden>

don't hide logging messages from python_name_lib

640. By Didier Roche-Tolomelli

Merge David's fix for fixing signal autoconnect does not work with
signal names which contain hypens (LP: #890318). Thanks!

639. By Michael Terry

fix tests to pass with latest platform and quickly changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/templates/ubuntu-application/create.py'
2--- data/templates/ubuntu-application/create.py 2011-06-06 10:14:40 +0000
3+++ data/templates/ubuntu-application/create.py 2011-12-05 00:02:27 +0000
4@@ -110,7 +110,7 @@
5 # run the new application if X display
6 if templatetools.is_X_display() and os.path.isfile(exec_file):
7 print _("Launching your newly created project!")
8- subprocess.call(['./' + project_name], cwd='bin/')
9+ subprocess.call(['./' + project_name, '-d'], cwd='bin/')
10
11 bzr_instance.wait()
12
13
14=== modified file 'data/templates/ubuntu-application/project_root/python/__init__.py'
15--- data/templates/ubuntu-application/project_root/python/__init__.py 2011-03-31 15:19:55 +0000
16+++ data/templates/ubuntu-application/project_root/python/__init__.py 2011-12-05 00:02:27 +0000
17@@ -18,11 +18,24 @@
18 def parse_options():
19 """Support for command line options"""
20 parser = optparse.OptionParser(version="%%prog %s" % get_version())
21- parser.add_option(
22- "-v", "--verbose", action="count", dest="verbose",
23- help=_("Show debug messages (-vv debugs python_name_lib also)"))
24+
25+ parser.add_option('-d', '--debug', dest='debug_mode', action='store_true',
26+ help=_('Print the maximum debugging info (implies -vv)'))
27+ parser.add_option('-v', '--verbose', dest='logging_level', action='count',
28+ help=_('set error_level output to warning, info, and then debug'))
29+
30+ ERROR, WARNING, INFO, DEBUG = range(4)
31+ parser.set_defaults(logging_level=ERROR)
32+
33 (options, args) = parser.parse_args()
34
35+ # set the verbosity
36+ if options.debug_mode:
37+ options.logging_level = DEBUG
38+
39+ if options.logging_level > DEBUG:
40+ options.logging_level = DEBUG
41+
42 set_up_logging(options)
43
44 def main():
45
46=== modified file 'data/templates/ubuntu-application/project_root/python_lib/Builder.py'
47--- data/templates/ubuntu-application/project_root/python_lib/Builder.py 2011-11-14 17:14:44 +0000
48+++ data/templates/ubuntu-application/project_root/python_lib/Builder.py 2011-12-05 00:02:27 +0000
49@@ -11,7 +11,7 @@
50 import inspect
51 import functools
52 import logging
53-logger = logging.getLogger('python_name_lib')
54+logger = logging.getLogger('python_name')
55
56 from xml.etree.cElementTree import ElementTree
57
58
59=== modified file 'data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py'
60--- data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py 2011-03-31 17:05:41 +0000
61+++ data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py 2011-12-05 00:02:27 +0000
62@@ -14,7 +14,7 @@
63
64 import gtk
65 import logging
66-logger = logging.getLogger('python_name_lib')
67+logger = logging.getLogger('python_name')
68
69 from . helpers import get_builder, show_uri, get_help_uri
70 from . preferences import preferences
71
72=== modified file 'data/templates/ubuntu-application/project_root/python_lib/Window.py'
73--- data/templates/ubuntu-application/project_root/python_lib/Window.py 2011-04-04 14:28:36 +0000
74+++ data/templates/ubuntu-application/project_root/python_lib/Window.py 2011-12-05 00:02:27 +0000
75@@ -5,7 +5,7 @@
76
77 import gtk
78 import logging
79-logger = logging.getLogger('python_name_lib')
80+logger = logging.getLogger('python_name')
81
82 from . helpers import get_builder, show_uri, get_help_uri
83 from . preferences import preferences
84
85=== modified file 'data/templates/ubuntu-application/project_root/python_lib/helpers.py'
86--- data/templates/ubuntu-application/project_root/python_lib/helpers.py 2011-03-31 17:05:41 +0000
87+++ data/templates/ubuntu-application/project_root/python_lib/helpers.py 2011-12-05 00:02:27 +0000
88@@ -46,6 +46,12 @@
89 def emit(self, record):
90 pass
91
92+LEVELS = ( logging.ERROR,
93+ logging.WARNING,
94+ logging.INFO,
95+ logging.DEBUG,
96+ )
97+
98 def set_up_logging(opts):
99 # add a handler to prevent basicConfig
100 root = logging.getLogger()
101@@ -59,17 +65,9 @@
102 logger_sh.setFormatter(formatter)
103 logger.addHandler(logger_sh)
104
105- lib_logger = logging.getLogger('python_name_lib')
106- lib_logger_sh = logging.StreamHandler()
107- lib_logger_sh.setFormatter(formatter)
108- lib_logger.addHandler(lib_logger_sh)
109-
110 # Set the logging level to show debug messages.
111- if opts.verbose:
112- logger.setLevel(logging.DEBUG)
113- logger.debug('logging enabled')
114- if opts.verbose > 1:
115- lib_logger.setLevel(logging.DEBUG)
116+ logger.setLevel(LEVELS[opts.logging_level])
117+ logger.debug('logging enabled')
118
119 def get_help_uri(page=None):
120 # help_uri from source tree - default language
121
122=== modified file 'data/templates/ubuntu-application/run.py'
123--- data/templates/ubuntu-application/run.py 2011-07-22 10:47:34 +0000
124+++ data/templates/ubuntu-application/run.py 2011-12-05 00:02:27 +0000
125@@ -54,6 +54,20 @@
126 command_line = [project_bin]
127 command_line.extend([arg for arg in sys.argv[1:] if arg != "--"])
128
129+# outside quickly log defaults to error
130+# and can be set to warning, info or debug
131+# inside quickly log defaults to debug
132+# and can be set to warning, info or debug
133+
134+LOGGING = False
135+for opt in command_line[1:]:
136+ if opt == '-d' or opt.startswith('-v'):
137+ LOGGING = True
138+
139+if not LOGGING:
140+ print 'automatic debug logging while running from quickly'
141+ command_line.extend('-d')
142+
143 # run with args if bin/project exist
144 st = os.stat(project_bin)
145 mode = st[stat.ST_MODE]

Subscribers

People subscribed via source and target branches