/** Actual writing occurs here. <p>Most subclasses of <code>WriterAppender</code> will need to override this method. @since 0.9.0 */ protected void subAppend(LoggingEvent event) { this.qw.write(this.layout.format(event)); if(layout.ignoresThrowable()) { String[] s = event.getThrowableStrRep(); if (s != null) { int len = s.length; for(int i = 0; i < len; i++) { this.qw.write(s[i]); this.qw.write(Layout.LINE_SEP); } } } if(shouldFlush(event)) { this.qw.flush(); } }
/** Sets the quiet writer being used. This method is overriden by {@link RollingFileAppender}. */ protected void setQWForFiles(Writer writer) { this.qw = new QuietWriter(writer, errorHandler); }
/** Set the {@link ErrorHandler} for this WriterAppender and also the underlying {@link QuietWriter} if any. */ public synchronized void setErrorHandler(ErrorHandler eh) { if(eh == null) { LogLog.warn("You have tried to set a null error-handler."); } else { this.errorHandler = eh; if(this.qw != null) { this.qw.setErrorHandler(eh); } } }
@Override protected void subAppend(LoggingEvent event) { if (!hackPatternString()) { qw.write(getColour(event.getLevel())); qw.write(getLayout().format(event)); } else { String color = getColour(event.getLevel()); qw.write(getLayout().format(event).replace(HIGHLIGHT_START, color)); } if (immediateFlush) qw.flush(); } }
/** * Close the underlying {@link java.io.Writer}. * */ protected void closeWriter() { if(qw != null) { try { qw.close(); } catch(IOException e) { if (e instanceof InterruptedIOException) { Thread.currentThread().interrupt(); } // There is do need to invoke an error handler at this late // stage. LogLog.error("Could not close " + qw, e); } } }
@Override public void flush() { if (qw != null) { qw.flush(); } }
public void write(String string) { super.write("<"+(syslogFacility | level)+">" + string); } }
public QuietWriter(Writer writer, ErrorHandler errorHandler) { super(writer); setErrorHandler(errorHandler); }
/** Closes the previously opened file. */ protected void closeFile() { if(this.qw != null) { try { this.qw.close(); } catch(java.io.IOException e) { if (e instanceof InterruptedIOException) { Thread.currentThread().interrupt(); } // Exceptionally, it does not make sense to delegate to an // ErrorHandler. Since a closed appender is basically dead. LogLog.error("Could not close " + qw, e); } } }
@Override public void flush() { if (qw != null) { qw.flush(); } }
public void write(String string) { super.write("<"+(syslogFacility | level)+">" + string); } }
public QuietWriter(Writer writer, ErrorHandler errorHandler) { super(writer); setErrorHandler(errorHandler); }
/** Actual writing occurs here. <p>Most subclasses of <code>WriterAppender</code> will need to override this method. @since 0.9.0 */ protected void subAppend(LoggingEvent event) { this.qw.write(this.layout.format(event)); if(layout.ignoresThrowable()) { String[] s = event.getThrowableStrRep(); if (s != null) { int len = s.length; for(int i = 0; i < len; i++) { this.qw.write(s[i]); this.qw.write(Layout.LINE_SEP); } } } if(this.immediateFlush) { this.qw.flush(); } }