www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Logging and tracing in D

reply "Andre Artus" <andre.artus gmail.com> writes:
What is the recommended approach for adding logging and tracing 
to D apps?
Is there a library for it?
Aug 05 2013
next sibling parent reply "evilrat" <evilrat666 gmail.com> writes:
On Tuesday, 6 August 2013 at 04:35:39 UTC, Andre Artus wrote:
 What is the recommended approach for adding logging and tracing 
 to D apps?
 Is there a library for it?
custom very simple yet powerful logging can be achieved with templates and debug specifier, something like this: -------------------- module logger; import std.datetime; import std.stdio : writefln; template log(T) { auto timeString = Clock.currTime().toISOExtString(); writefln("log message from(%s)[+%s]: %s", __FUNCTION__, timeString, T); } -------------------- then in ur code just place with debug specifier: -------------------- import logger; void main { debug log!"my stuff"; } -------------------- and you get pretty formatted message in console(add log file writer if needed), and you get "smart" logging for free, in that way it will be generated only for debug mode(in release it will be skipped because of debug specifier).
Aug 06 2013
parent reply "Andre Artus" <andre.artus gmail.com> writes:
-- snip--
 and you get pretty formatted message in console(add log file 
 writer if needed), and you get "smart" logging for free, in 
 that way it will be generated only for debug mode(in release it 
 will be skipped because of debug specifier).
Thanks, can I take it that there is no official library for this kind of thing then? I would think it generally useful. Perhaps it can be considered for inclusion into Phobos.
Aug 06 2013
next sibling parent reply David <d dav1d.de> writes:
Am 06.08.2013 19:22, schrieb Andre Artus:
 -- snip--
 and you get pretty formatted message in console(add log file writer if
 needed), and you get "smart" logging for free, in that way it will be
 generated only for debug mode(in release it will be skipped because of
 debug specifier).
Thanks, can I take it that there is no official library for this kind of thing then? I would think it generally useful. Perhaps it can be considered for inclusion into Phobos.
There is std.log (proposed), it doesn't work, I don't like its API. I wrote my own logger (consider it MIT licensed) https://github.com/Dav1dde/BraLa/blob/master/brala/utils/log.d I am not 100% happy how it turned out, but I haven't come around to change it, but it works pretty well.
Aug 06 2013
parent reply "Andre Artus" <andre.artus gmail.com> writes:
 David wrote:
 Am 06.08.2013 19:22, schrieb Andre Artus:
 -- snip--
 and you get pretty formatted message in console(add log file 
 writer if
 needed), and you get "smart" logging for free, in that way it 
 will be
 generated only for debug mode(in release it will be skipped 
 because of
 debug specifier).
Thanks, can I take it that there is no official library for this kind of thing then? I would think it generally useful. Perhaps it can be considered for inclusion into Phobos.
There is std.log (proposed), it doesn't work, I don't like its API.
I take it that it hasn't been documented yet, at least I could not find it on dlang.org.
 David:
 I wrote my own logger (consider it MIT licensed)
 https://github.com/Dav1dde/BraLa/blob/master/brala/utils/log.d

 I am not 100% happy how it turned out, but I haven't come 
 around to
 change it, but it works pretty well.
Cool, thanks, I'll check it out.
Aug 06 2013
next sibling parent reply David <d dav1d.de> writes:
Am 06.08.2013 20:54, schrieb Andre Artus:
 David wrote:
 Am 06.08.2013 19:22, schrieb Andre Artus:
 -- snip--
 and you get pretty formatted message in console(add log file writer if
 needed), and you get "smart" logging for free, in that way it will be
 generated only for debug mode(in release it will be skipped because of
 debug specifier).
Thanks, can I take it that there is no official library for this kind of thing then? I would think it generally useful. Perhaps it can be considered for inclusion into Phobos.
There is std.log (proposed), it doesn't work, I don't like its API.
I take it that it hasn't been documented yet, at least I could not find it on dlang.org.
It's currently in the review queue: http://wiki.dlang.org/Review_Queue but marked on hold/suspended.
Aug 06 2013
parent "Andre Artus" <andre.artus gmail.com> writes:
-- snip --
 I take it that it hasn't been documented yet, at least I could 
 not find
 it on dlang.org.
It's currently in the review queue: http://wiki.dlang.org/Review_Queue but marked on hold/suspended.
Thanks, I'll check it out later.
Aug 06 2013
prev sibling next sibling parent "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Tuesday, 6 August 2013 at 18:54:50 UTC, Andre Artus wrote:
 David wrote:
 There is std.log (proposed), it doesn't work, I don't like its 
 API.
I take it that it hasn't been documented yet, at least I could not find it on dlang.org.
http://wiki.dlang.org/Review_Queue
Aug 06 2013
prev sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Aug 06, 2013 at 08:54:48PM +0200, Andre Artus wrote:
David wrote:
Am 06.08.2013 19:22, schrieb Andre Artus:
-- snip--
and you get pretty formatted message in console(add log file writer
if needed), and you get "smart" logging for free, in that way it
will be generated only for debug mode(in release it will be skipped
because of debug specifier).
Thanks, can I take it that there is no official library for this kind of thing then? I would think it generally useful. Perhaps it can be considered for inclusion into Phobos.
There is std.log (proposed), it doesn't work, I don't like its API.
I take it that it hasn't been documented yet, at least I could not find it on dlang.org.
[...] Sounds like it's not merged into the official codebase yet. T -- Always remember that you are unique. Just like everybody else. -- despair.com
Aug 06 2013
prev sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Aug 06, 2013 at 07:22:11PM +0200, Andre Artus wrote:
 -- snip--
and you get pretty formatted message in console(add log file
writer if needed), and you get "smart" logging for free, in that
way it will be generated only for debug mode(in release it will be
skipped because of debug specifier).
Thanks, can I take it that there is no official library for this kind of thing then? I would think it generally useful. Perhaps it can be considered for inclusion into Phobos.
This is strange. I clearly remember some time ago that there was a logging module in the Phobos review queue. But after the initial feedback, I haven't heard anything from it since. What's going on? Has it been abandoned? T -- Those who've learned LaTeX swear by it. Those who are learning LaTeX swear at it. -- Pete Bleackley
Aug 06 2013
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2013-08-06 06:35, Andre Artus wrote:
 What is the recommended approach for adding logging and tracing to D apps?
 Is there a library for it?
Tango contains a package for logging: Docs/tutorial: http://dsource.org/projects/tango/wiki/ChapterLogging API reference: http://dsource.org/projects/tango/docs/current/ D2 port: https://github.com/SiegeLord/Tango-D2 -- /Jacob Carlborg
Aug 07 2013