public static void log(String s) { if (diag_logger != null) { diag_logger.log(s); } }
public static synchronized AEDiagnosticsLogger getLogger( String name ) { AEDiagnosticsLogger logger = loggers.get(name); if ( logger == null ){ startup( false ); logger = new AEDiagnosticsLogger( debug_dir, name, MAX_FILE_SIZE_ACTUAL, !enable_pending_writes ); loggers.put( name, logger ); } return( logger ); }
public static String getTimestamp() { long time = SystemTime.getCurrentTime(); time += timezone_offset; // we'll live with this changing... time /= 1000; int secs = (int)time % 60; int mins = (int)(time / 60) % 60; int hours = (int)(time /3600) % 24; char[] chars = new char[11]; chars[0] = '['; format( hours, chars, 1 ); chars[3] = ':'; format( mins, chars, 4 ); chars[6] = ':'; format( secs, chars, 7 ); chars[9] = ']'; chars[10] = ' '; return( new String( chars )); }
timeStamp = getTimestamp(); writePending(); write( str );
diagnostic_logger.setMaxFileSize((int)max_file_size ); diagnostic_logger.enableTimeStamp( !timestamp && diag_timestamp );
public void logAndOut( String str ) { logAndOut( str, false ); }
protected AEDiagnosticsLogger( File _debug_dir, String _name, int[] _max_size, boolean _direct_writes ) { debug_dir = _debug_dir; name = _name; max_size = _max_size; direct_writes = _direct_writes; try{ File f1 = getLogFile(); first_file = false; File f2 = getLogFile(); first_file = true; // if we were writing to the second file, carry on from there if ( f1.exists() && f2.exists()){ if ( f1.lastModified() < f2.lastModified()){ first_file = false; } } }catch( Throwable ignore ){ } }
@Override public void setForce( boolean forceToFile) { diagnostic_logger.setForced( forceToFile ); }
@Override public boolean getForce() { return( diagnostic_logger.isForced()); }
private File getLogFile() { return( new File( debug_dir, getName() + "_" + (first_file?"1":"2") + ".log" )); }
private static void diagLoggerLogAndOut( Throwable e ) { // handle possible recursive initialisation problems where the init of diag-logger gets // back here.... if ( diag_logger == null ){ e.printStackTrace(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter( sw ); e.printStackTrace( pw ); pw.close(); writeEmergencyLog( sw.toString()); }else{ diag_logger.logAndOut( e ); } }
File log_file = getLogFile(); log_file = getLogFile();
private static void diagLoggerLogAndOut( String str, boolean stderr ) { // handle possible recursive initialisation problems where the init of diag-logger gets // back here.... if ( diag_logger == null ){ if ( stderr ){ System.err.println( str ); }else{ System.out.println( str ); } writeEmergencyLog( str ); }else{ diag_logger.logAndOut( str, stderr ); } } private static void
File log_file = getLogFile(); log_file = getLogFile();
@Override public void log( String str ) { if ( DEBUG ){ logger.log( str ); } }
@Override public void messageLogged( int type, String content ) { diagnostic_logger.log( content ); }
private static void diagLoggerLog(String str) { if ( diag_logger == null ){ System.out.println( str ); }else{ diag_logger.log(str); } }
public void logAndOut( Throwable e ) { e.printStackTrace(); log( e ); }