Suggestion for approach to adding timestamp to a MessageHandler?

14 views
Skip to first unread message

Hugh Macdonald

unread,
Oct 24, 2016, 5:28:12 AM10/24/16
to cort...@googlegroups.com
Hi all,

I've been wanting to get a message handler that'll add a timestamp at the start of each message. I didn't want to re-implement OStreamMessageHandler, so I looked into either subclassing it or wrapping it (in the way that FilteredMessageHandler does)

Subclassing it could have worked, but I'd have had to store my own stream reference, as m_stream in OStreamMessageHandler is private.

Wrapping it is what I ended up trying out, and replacing context with "<timestamp> : <context>", however, this is placed after the level string.

Wrapping it would be my preference, as then I could use it with any other Message Handlers (I could see myself using a CompoundMessageHandler with both an OStreamMessageHandler and maybe my own Qt MessageHandlerWidget).

Any suggestions on this? I'm guessing that the MessageHandler interface is probably well and truly locked down, so adding it in as an option at a lower level wouldn't be feasible, but maybe I'm wrong there...?


Thanks

Hugh Macdonald
nvizible – VISUAL EFFECTS
nvizage – PREVISUALIZATION
www.nvizage.com

john haddon

unread,
Oct 24, 2016, 5:36:16 AM10/24/16
to cortexdev
Hi Hugh,

We can't add anything to the virtual interface for MessageHandler at this point, because it would break binary compatibility. It is something we could consider for the future though - do you have a proposal in that regard?

If you did want to subclass OStreamMessageHandler, we could provide protected access to `m_stream` without a problem.

Cheers...
John

Hugh Macdonald

unread,
Oct 24, 2016, 9:15:10 AM10/24/16
to cort...@googlegroups.com
Thanks - that all makes sense.

If we could make m_stream protected rather than private, that would definitely help. I can do a PR for it when I get a chance.

Thanks

Hugh Macdonald
Nvizible - Visual Effects

020 3167 3860
07773 764708
--
--
You received this message because you are subscribed to the "cortexdev" group.
To post to this group, send email to cort...@googlegroups.com
To unsubscribe from this group, send email to cortexdev-...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cortexdev?hl=en
---
You received this message because you are subscribed to the Google Groups "cortexdev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cortexdev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages