rendered paste bodydiff -r 490206ac8a6a base/src/java/lang/exceptions.d--- a/base/src/java/lang/exceptions.d Tue Jul 13 17:10:14 2010 +0200+++ b/base/src/java/lang/exceptions.d Tue Jul 13 22:03:48 2010 +0200@@ -170,23 +170,22 @@ } /// Extension to the D Exception-void ExceptionPrintStackTrace( Exception e ){- ExceptionPrintStackTrace( e, & getDwtLogger().error );-}--/// Extension to the D Exception-void ExceptionPrintStackTrace( Throwable e, void delegate ( String file, ulong line, String fmt, ... ) dg ){+void ExceptionPrintStackTrace( Throwable e, bool infoOnly=false ){ version (D_Version2){ // D 2 stacktrace info is different.- //implMissing(__FILE__, __LINE__);- dg( e.file, e.line, e.toString() );+ // Phobos currently has stack tracing only on Linux.+ // Revisit this when that changes.+ auto print = infoOnly ? &getDwtLogger().info!() : &getDwtLogger.error!();+ print( e.file, e.line, e.toString() ); }else{+ auto print = infoOnly ? &getDwtLogger().info!(String, long, String) :+ &getDwtLogger().error!(String, long, String); Throwable exception = e; while( exception !is null ){- dg( exception.file, exception.line, "Exception in {}({}): {}", exception.file, exception.line, exception.msg );+ print( exception.file, exception.line, "Exception in {}({}): {}", exception.file, exception.line, exception.msg ); if( exception.info !is null ){ foreach( frame; exception.info ){- dg( exception.file, exception.line, "trc {} {}", frame.file, frame.line );+ print( exception.file, exception.line, "trc {} {}", frame.file, frame.line, "" ); } } exception = exception.next;diff -r 490206ac8a6a base/src/java/lang/util.d--- a/base/src/java/lang/util.d Tue Jul 13 17:10:14 2010 +0200+++ b/base/src/java/lang/util.d Tue Jul 13 22:03:48 2010 +0200@@ -28,77 +28,79 @@ String GSHARED(String s) { return s; } } --interface IDwtLogger {- void trace( String file, ulong line, String fmt, ... );- void info( String file, ulong line, String fmt, ... );- void warn( String file, ulong line, String fmt, ... );- void error( String file, ulong line, String fmt, ... );- void fatal( String file, ulong line, String fmt, ... );-}- version(Tango){- class DwtLogger : IDwtLogger {+ class DwtLogger { tango.util.log.Log.Logger logger; private this( char[] name ){ logger = tango.util.log.Log.Log.lookup( name ); }- private char[] format( String file, ulong line, String fmt, TypeInfo[] types, void* argptr ){- auto msg = Format.convert( types, argptr, fmt );+ char[] format( T... )( String file, ulong line, String fmt, T args ){+ auto msg = Format( fmt, args ); auto text = Format( "{} {}: {}", file, line, msg ); return text; }- void trace( String file, ulong line, String fmt, ... ){+ void trace(T...)(String file, ulong line, String fmt, T args){ if( logger.trace ){- logger.trace( format( file, line, fmt, _arguments, _argptr ));+ logger.trace( format( file, line, fmt, args )); } }- void info( String file, ulong line, String fmt, ... ){+ void info(T...)(String file, ulong line, String fmt, T args){ if( logger.info ){- logger.info( format( file, line, fmt, _arguments, _argptr ));+ logger.info( format( file, line, fmt, args )); } }- void warn( String file, ulong line, String fmt, ... ){+ void warn(T...)(String file, ulong line, String fmt, T args){ if( logger.warn ){- logger.warn( format( file, line, fmt, _arguments, _argptr ));+ logger.warn( format( file, line, fmt, args )); } }- void error( String file, ulong line, String fmt, ... ){+ void error(T...)(String file, ulong line, String fmt, T args){ if( logger.error ){- logger.error( format( file, line, fmt, _arguments, _argptr ));+ logger.error( format( file, line, fmt, args )); } }- void fatal( String file, ulong line, String fmt, ... ){+ void fatal(T...)(String file, ulong line, String fmt, T args){ if( logger.fatal ){- logger.fatal( format( file, line, fmt, _arguments, _argptr ));+ logger.fatal( format( file, line, fmt, args)); } } } } else { // Phobos- class DwtLogger : IDwtLogger {+ class DwtLogger { private this( String name ){ }- void trace( String file, ulong line, String fmt, ... ){- std.stdio.writefln( "TRC %s %d: %s", file, line, fmt );+ private void writeLine( T... )( String prefix, String file, ulong line, String fmt, T args )+ {+ std.stdio.write( prefix, " ", file, " ", line, ": " );+ fmt = std.string.replace( fmt, "{}", "%s" );+ std.stdio.writefln(fmt, args); }- void info( String file, ulong line, String fmt, ... ){- std.stdio.writefln( "INF %s %d: %s", file, line, fmt );+ void trace( T... )( String file, ulong line, String fmt, T args )+ {+ writeLine( "TRC", file, line, fmt, args ); }- void warn( String file, ulong line, String fmt, ... ){- std.stdio.writefln( "WRN %s %d: %s", file, line, fmt );+ void info( T... )( String file, ulong line, String fmt, T args )+ {+ writeLine( "INF", file, line, fmt, args ); }- void error( String file, ulong line, String fmt, ... ){- std.stdio.writefln( "ERR %s %d: %s", file, line, fmt );+ void warn( T... )( String file, ulong line, String fmt, T args )+ {+ writeLine( "WRN", file, line, fmt, args ); }- void fatal( String file, ulong line, String fmt, ... ){- std.stdio.writefln( "FAT %s %d: %s", file, line, fmt );+ void error( T... )( String file, ulong line, String fmt, T args )+ {+ writeLine( "ERR", file, line, fmt, args );+ }+ void fatal( T... )( String file, ulong line, String fmt, T args )+ {+ writeLine( "FAT", file, line, fmt, args ); } } } private mixin(GSHARED(`DwtLogger dwtLoggerInstance;`)); -IDwtLogger getDwtLogger(){+DwtLogger getDwtLogger(){ if( dwtLoggerInstance is null ){ synchronized{ if( dwtLoggerInstance is null ){