Bug 26516

Summary: TpDebugSender log handler conflicts with tp_debug_timestamped_log_handler
Product: Telepathy Reporter: Simon McVittie <smcv>
Component: tp-glibAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium Keywords: patch
Version: git master   
Hardware: Other   
OS: All   
URL: http://cgit.collabora.com/git/user/wjt/telepathy-glib.git/log/?h=qed
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 26517    

Description Simon McVittie 2010-02-10 09:18:40 UTC
tp_debug_timestamped_log_handler and tp_debug_sender_log_handler can't be used at the same time. It'd probably be more useful to have some way to set up tp_debug_sender_log_handler so it timestamps any messages that it sends to stdout/stderr, perhaps via a function like

    void tp_debug_sender_set_timestamps (gboolean maybe);

which can be called conditionally on a FOO_TIMING environment variable.

Alternatively, since we're fetching a GTimeVal for the debug sender's benefit *anyway*, we could just use timestamps unconditionally.
Comment 1 Jonny Lamb 2011-01-10 06:04:49 UTC
Take, review; this is my patch.
Comment 2 Simon McVittie 2011-01-10 06:31:05 UTC
fe8dd650a78d r+, and please cherry-pick to 0.12 too.

In the second commit, I'm a bit sad that tp_debug_sender_log_handler now potentially calls g_get_current_time twice.
Comment 3 Jonny Lamb 2011-01-10 08:03:49 UTC
(In reply to comment #2)
> fe8dd650a78d r+, and please cherry-pick to 0.12 too.

Cheers.

> In the second commit, I'm a bit sad that tp_debug_sender_log_handler now
> potentially calls g_get_current_time twice.

Yeah I wondered about that. Got a nice solution in mind?
Comment 4 Will Thompson 2011-01-10 08:22:27 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > fe8dd650a78d r+, and please cherry-pick to 0.12 too.
> 
> Cheers.
> 
> > In the second commit, I'm a bit sad that tp_debug_sender_log_handler now
> > potentially calls g_get_current_time twice.
> 
> Yeah I wondered about that. Got a nice solution in mind?

If we could find a GSource kicking around we could use g_source_get_current_time() which is really cheap.
Comment 5 Will Thompson 2011-06-29 02:52:17 UTC
Hello.

+ * If timestamps should be prepended to messages (like in
+ * tp_debug_timestamped_log_handler()), tp_debug_sender_set_messages()
+ * should also be called.

That function doesn't exist.

(In reply to comment #3)
> Yeah I wondered about that. Got a nice solution in mind?

Oh, it's literally twice in the same function, not indirected through a bunch of function calls.

Float GTimeVal now = { 0, 0 }; out to the top-level scope in the function, and in the second branch only call g_get_current_time if now.tv_sec == 0? I don't think you're gonna get nicer than that.
Comment 6 Will Thompson 2011-06-29 03:55:10 UTC
I have rebased the branch and fixed my own criticisms.
Comment 7 Xavier Claessens 2011-08-02 04:11:37 UTC
looks good, +1
Comment 8 Will Thompson 2011-08-04 10:15:19 UTC
Merged for 0.15.5; thanks for the review!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.