Merge lp:~mikemc/unity-scope-click/log-improvements into lp:unity-scope-click

Proposed by Mike McCracken
Status: Merged
Approved by: dobey
Approved revision: 101
Merged at revision: 102
Proposed branch: lp:~mikemc/unity-scope-click/log-improvements
Merge into: lp:unity-scope-click
Diff against target: 104 lines (+19/-7)
3 files modified
src/Makefile.am (+1/-1)
src/click-scope-main.vala (+7/-3)
src/click-scope.vala (+11/-3)
To merge this branch: bzr merge lp:~mikemc/unity-scope-click/log-improvements
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
dobey (community) Approve
Review via email: mp+200600@code.launchpad.net

Commit message

- Add timestamps to log messages and ensure that all debug() messages are written to disk.

Description of the change

- Add timestamps to log messages and ensure that all debug() messages are written to disk.

Adds timestamps to messages - both those written to screen if G_MESSAGES_DEBUG=all is set, and to those written to ~/.cache/unity-scope-click.log

Fixes typo in makefile to correctly set G_LOG_DOMAIN, and uses domain to ensure that log file only gets sent messages from our code.

To post a comment you must log in.
100. By Mike McCracken

Tag as fixing bug LP: #1266583

Revision history for this message
dobey (dobey) wrote :

30 - Log.set_handler ("unity-scope-click", LogLevelFlags.LEVEL_MASK,
31 + Log.set_handler (null, LogLevelFlags.LEVEL_MASK,

I don't understand why you made this change. You want log messages from all the underlying libraries to go to the file too?

53 internal async Unity.Preview build_app_preview(Unity.ScopeResult result) {
54 + debug ("build_app_preview");
55 var app_id = result.metadata.get(METADATA_APP_ID).get_string();

Different spacing here on the added line.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
101. By Mike McCracken

fix G_LOG_DOMAIN typo, revert to using unity-scope-click as domain for custom handler. Fix whitespace issue.

Revision history for this message
Mike McCracken (mikemc) wrote :

@dobey, Thanks for pointing out the hole in my understanding of the log domain. Fixed that, now the file only contains messages from the unity-scope-click domain.

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2013-12-18 19:19:12 +0000
+++ src/Makefile.am 2014-01-06 22:37:10 +0000
@@ -3,7 +3,7 @@
3 -g -w \3 -g -w \
4 $(COVERAGE_CFLAGS) \4 $(COVERAGE_CFLAGS) \
5 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \5 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
6 -D_LOG_DOMAIN=\"unity-scope-click\" \6 -DG_LOG_DOMAIN=\"unity-scope-click\" \
7 $(SCOPE_DAEMON_CFLAGS) \7 $(SCOPE_DAEMON_CFLAGS) \
8 $(OTHERS_CFLAGS) \8 $(OTHERS_CFLAGS) \
9 -I$(srcdir) \9 -I$(srcdir) \
1010
=== modified file 'src/click-scope-main.vala'
--- src/click-scope-main.vala 2013-12-05 20:35:45 +0000
+++ src/click-scope-main.vala 2014-01-06 22:37:10 +0000
@@ -42,14 +42,18 @@
42 LogLevelFlags level,42 LogLevelFlags level,
43 string message)43 string message)
44{44{
45 Log.default_handler (domain, level, message);45 var now = new DateTime.now_local ();
46 string timestamp = now.format ("%T");
47 var msg = "%s: %s".printf(timestamp, message);
48
49 Log.default_handler (domain, level, msg);
4650
47 try {51 try {
48 var log_stream = log_file.append_to (FileCreateFlags.NONE);52 var log_stream = log_file.append_to (FileCreateFlags.NONE);
4953
50 if (log_stream != null) {54 if (log_stream != null) {
51 string log_message = "[%s] - %s: %s\n".printf(55 string log_message = "%-7s %s: %s\n".printf(
52 domain, _level_string (level), message);56 _level_string (level), timestamp, message);
53 log_stream.write (log_message.data);57 log_stream.write (log_message.data);
54 log_stream.flush ();58 log_stream.flush ();
55 log_stream.close ();59 log_stream.close ();
5660
=== modified file 'src/click-scope.vala'
--- src/click-scope.vala 2013-12-24 00:33:07 +0000
+++ src/click-scope.vala 2014-01-06 22:37:10 +0000
@@ -55,8 +55,10 @@
55 }55 }
5656
57 public override void run_async (Unity.AbstractPreviewCallback async_callback) {57 public override void run_async (Unity.AbstractPreviewCallback async_callback) {
58 debug ("ClickPreviewer: run_async()");
58 scope.build_default_preview.begin(result, (obj, res) => {59 scope.build_default_preview.begin(result, (obj, res) => {
59 var preview = scope.build_default_preview.end(res);60 var preview = scope.build_default_preview.end(res);
61 debug ("ClickPreviewer: run_async() done, calling async_callback");
60 async_callback (this, preview);62 async_callback (this, preview);
61 });63 });
62 }64 }
@@ -113,6 +115,7 @@
113 }115 }
114116
115 internal async Unity.Preview build_app_preview(Unity.ScopeResult result) {117 internal async Unity.Preview build_app_preview(Unity.ScopeResult result) {
118 debug ("build_app_preview");
116 var app_id = result.metadata.get(METADATA_APP_ID).get_string();119 var app_id = result.metadata.get(METADATA_APP_ID).get_string();
117 try {120 try {
118 var details = yield webservice.get_details(app_id);121 var details = yield webservice.get_details(app_id);
@@ -136,8 +139,10 @@
136 }139 }
137140
138 public async virtual Unity.Preview build_uninstalled_preview (Unity.ScopeResult result) {141 public async virtual Unity.Preview build_uninstalled_preview (Unity.ScopeResult result) {
142 Unity.Preview preview = yield build_app_preview (result);
143 debug ("build_uninstalled_preview");
144
139 var price = result.metadata.get(METADATA_PRICE).get_double();145 var price = result.metadata.get(METADATA_PRICE).get_double();
140 Unity.Preview preview = yield build_app_preview (result);
141 if (!(preview is Unity.GenericPreview)) {146 if (!(preview is Unity.GenericPreview)) {
142 if (price == 0.0f) {147 if (price == 0.0f) {
143 preview.add_action (new Unity.PreviewAction (ACTION_INSTALL_CLICK, ("Install"), null));148 preview.add_action (new Unity.PreviewAction (ACTION_INSTALL_CLICK, ("Install"), null));
@@ -149,10 +154,12 @@
149 }154 }
150155
151 public async virtual Unity.Preview build_installed_preview (Unity.ScopeResult result, string application_uri) {156 public async virtual Unity.Preview build_installed_preview (Unity.ScopeResult result, string application_uri) {
152 var app_id = result.metadata.get(METADATA_APP_ID).get_string();
153 Unity.Preview preview = yield build_app_preview (result);157 Unity.Preview preview = yield build_app_preview (result);
158 debug ("build_installed_preview");
159
154 preview.add_action (new Unity.PreviewAction (ACTION_OPEN_CLICK + ":" + application_uri, ("Open"), null));160 preview.add_action (new Unity.PreviewAction (ACTION_OPEN_CLICK + ":" + application_uri, ("Open"), null));
155161
162 var app_id = result.metadata.get(METADATA_APP_ID).get_string();
156 if (yield click_if.can_uninstall (app_id)) {163 if (yield click_if.can_uninstall (app_id)) {
157 preview.add_action (new Unity.PreviewAction (ACTION_UNINSTALL_CLICK, ("Uninstall"), null));164 preview.add_action (new Unity.PreviewAction (ACTION_UNINSTALL_CLICK, ("Uninstall"), null));
158 }165 }
@@ -161,7 +168,7 @@
161168
162 public async virtual Unity.Preview build_installing_preview (Unity.ScopeResult result, string progress_source) {169 public async virtual Unity.Preview build_installing_preview (Unity.ScopeResult result, string progress_source) {
163 Unity.Preview preview = yield build_app_preview (result);170 Unity.Preview preview = yield build_app_preview (result);
164171 debug ("build_installing_preview");
165 // When the progressbar is shown by the preview in the dash no buttons should be shown.172 // When the progressbar is shown by the preview in the dash no buttons should be shown.
166 // The two following actions (marked with ***) are not shown as buttons, but instead are triggered by the dash173 // The two following actions (marked with ***) are not shown as buttons, but instead are triggered by the dash
167 // when the download manager succeeds or fails with a given download+installation.174 // when the download manager succeeds or fails with a given download+installation.
@@ -287,6 +294,7 @@
287294
288 MainLoop mainloop = new MainLoop ();295 MainLoop mainloop = new MainLoop ();
289 activate_async.begin(result, metadata, action_id, (obj, res) => {296 activate_async.begin(result, metadata, action_id, (obj, res) => {
297 debug ("activate_async: done.");
290 response = activate_async.end(res);298 response = activate_async.end(res);
291 mainloop.quit ();299 mainloop.quit ();
292 });300 });

Subscribers

People subscribed via source and target branches

to all changes: