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
1=== modified file 'src/Makefile.am'
2--- src/Makefile.am 2013-12-18 19:19:12 +0000
3+++ src/Makefile.am 2014-01-06 22:37:10 +0000
4@@ -3,7 +3,7 @@
5 -g -w \
6 $(COVERAGE_CFLAGS) \
7 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
8- -D_LOG_DOMAIN=\"unity-scope-click\" \
9+ -DG_LOG_DOMAIN=\"unity-scope-click\" \
10 $(SCOPE_DAEMON_CFLAGS) \
11 $(OTHERS_CFLAGS) \
12 -I$(srcdir) \
13
14=== modified file 'src/click-scope-main.vala'
15--- src/click-scope-main.vala 2013-12-05 20:35:45 +0000
16+++ src/click-scope-main.vala 2014-01-06 22:37:10 +0000
17@@ -42,14 +42,18 @@
18 LogLevelFlags level,
19 string message)
20 {
21- Log.default_handler (domain, level, message);
22+ var now = new DateTime.now_local ();
23+ string timestamp = now.format ("%T");
24+ var msg = "%s: %s".printf(timestamp, message);
25+
26+ Log.default_handler (domain, level, msg);
27
28 try {
29 var log_stream = log_file.append_to (FileCreateFlags.NONE);
30
31 if (log_stream != null) {
32- string log_message = "[%s] - %s: %s\n".printf(
33- domain, _level_string (level), message);
34+ string log_message = "%-7s %s: %s\n".printf(
35+ _level_string (level), timestamp, message);
36 log_stream.write (log_message.data);
37 log_stream.flush ();
38 log_stream.close ();
39
40=== modified file 'src/click-scope.vala'
41--- src/click-scope.vala 2013-12-24 00:33:07 +0000
42+++ src/click-scope.vala 2014-01-06 22:37:10 +0000
43@@ -55,8 +55,10 @@
44 }
45
46 public override void run_async (Unity.AbstractPreviewCallback async_callback) {
47+ debug ("ClickPreviewer: run_async()");
48 scope.build_default_preview.begin(result, (obj, res) => {
49 var preview = scope.build_default_preview.end(res);
50+ debug ("ClickPreviewer: run_async() done, calling async_callback");
51 async_callback (this, preview);
52 });
53 }
54@@ -113,6 +115,7 @@
55 }
56
57 internal async Unity.Preview build_app_preview(Unity.ScopeResult result) {
58+ debug ("build_app_preview");
59 var app_id = result.metadata.get(METADATA_APP_ID).get_string();
60 try {
61 var details = yield webservice.get_details(app_id);
62@@ -136,8 +139,10 @@
63 }
64
65 public async virtual Unity.Preview build_uninstalled_preview (Unity.ScopeResult result) {
66+ Unity.Preview preview = yield build_app_preview (result);
67+ debug ("build_uninstalled_preview");
68+
69 var price = result.metadata.get(METADATA_PRICE).get_double();
70- Unity.Preview preview = yield build_app_preview (result);
71 if (!(preview is Unity.GenericPreview)) {
72 if (price == 0.0f) {
73 preview.add_action (new Unity.PreviewAction (ACTION_INSTALL_CLICK, ("Install"), null));
74@@ -149,10 +154,12 @@
75 }
76
77 public async virtual Unity.Preview build_installed_preview (Unity.ScopeResult result, string application_uri) {
78- var app_id = result.metadata.get(METADATA_APP_ID).get_string();
79 Unity.Preview preview = yield build_app_preview (result);
80+ debug ("build_installed_preview");
81+
82 preview.add_action (new Unity.PreviewAction (ACTION_OPEN_CLICK + ":" + application_uri, ("Open"), null));
83
84+ var app_id = result.metadata.get(METADATA_APP_ID).get_string();
85 if (yield click_if.can_uninstall (app_id)) {
86 preview.add_action (new Unity.PreviewAction (ACTION_UNINSTALL_CLICK, ("Uninstall"), null));
87 }
88@@ -161,7 +168,7 @@
89
90 public async virtual Unity.Preview build_installing_preview (Unity.ScopeResult result, string progress_source) {
91 Unity.Preview preview = yield build_app_preview (result);
92-
93+ debug ("build_installing_preview");
94 // When the progressbar is shown by the preview in the dash no buttons should be shown.
95 // The two following actions (marked with ***) are not shown as buttons, but instead are triggered by the dash
96 // when the download manager succeeds or fails with a given download+installation.
97@@ -287,6 +294,7 @@
98
99 MainLoop mainloop = new MainLoop ();
100 activate_async.begin(result, metadata, action_id, (obj, res) => {
101+ debug ("activate_async: done.");
102 response = activate_async.end(res);
103 mainloop.quit ();
104 });

Subscribers

People subscribed via source and target branches

to all changes: