Changeset 410 for trunk/log_api

Show
Ignore:
Timestamp:
08/13/08 13:27:08 (4 years ago)
Author:
BCS
Message:

better return value logging
header comment

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/log_api/LogAPI.d

    r409 r410  
    11import std.stdio; 
     2/** 
     3The intended use for this lib is for debugging the external API's. For example  
     4I wrote it because I was having issues with a mysql wrapper lib and wanted to  
     5known what api calls were being made. 
     6 
     7To use it, replace the call to be logged with a wrapped call: 
     8 
     9ulong r = mysql_real_escape_string(connection, ret.ptr, string.ptr, string.length); 
     10ulong r = TraceAPI!("mysql_real_escape_string)(__FILE__,__LINE__,connection, ret.ptr, string.ptr, string.length); 
     11 
     12a little fun with regex and you can have a whole file done in about a minute 
     13 
     14This software is distributed without any warranty of any kind and is NOT suitable for any  
     15production usage.  
     16 
     17Author: Benjamin Shropshire  shro8822 -> vandals uidaho edu 
     18*/ 
    219 
    320template MixinTraceAPI() 
     
    3754            { 
    3855                R ret = mixin(fn~"(t)"); 
    39                 debug(runTimeTrace) writef(" %s:%s %s  = %s\n",file, line, fn, ret); 
     56                debug(runTimeTrace) writef(" %s:%s %s  = ",file, line, fn); 
     57                static if(is(R == char*)) 
     58                    writef(`"%s"\n`, ret[0..strlen(ret)]); 
     59                else static if(is(R : int)) 
     60                    writef("%d\n", ret); 
     61                else 
     62                    writef("[%s]%s\n", R.stringof,ret); 
    4063                return ret; 
    4164            }