new scrapple Lib: API logging

Christopher Wright dhasenan at gmail.com
Wed Aug 13 19:10:29 PDT 2008


BCS wrote:
> (lets try this again in the correct NG :)
> 
> I have posted a new library to scrapple.
> 
> http://www.dsource.org/projects/scrapple/browser/trunk/log_api
> 
> This library allows simple wrapping of function calls with logging of 
> file name/line number of call, function name and argument/return values.
> 
> The intended use for this lib is for debugging the external API's. For 
> example
> 
> I wrote it because I was having issues with a mysql wrapper lib and 
> wanted to known what api calls were being made.
> 
> To use it, replace the calls to be logged with wrapped calls:
> 
> ulong r = mysql_real_escape_string(connection, ret.ptr, string.ptr, 
> string.length); ulong r = 
> TraceAPI!("mysql_real_escape_string)(__FILE__,__LINE__,connection, 
> ret.ptr, string.ptr, string.length);

This is really ugly, but it does a good thing.

Maybe you could incorporate jive.stacktrace (or one of the hacked 
versions that actually works) so you don't have to use __FILE__, 
__LINE__? Though that's probably more than you want to do.

Also, have you tried alias parameters rather than strings? It results in 
more sensible error messages.


More information about the Digitalmars-d-announce mailing list