Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 17 package org.apache.avalon.framework.logger; 18 19 import java.io.ByteArrayOutputStream ; 20 import java.io.IOException ; 21 import java.io.OutputStream ; 22 23 47 public abstract class LoggerAwareOutputStream extends OutputStream  48 { 49 54 public LoggerAwareOutputStream( Logger logger ) { 55 m_logger = logger; 56 } 57 58 66 public void write( int b ) throws IOException  67 { 68 if ( b == '\n' ) 69 { 70 final byte[] content = bos.toByteArray(); 71 logMessage( new String ( content ) ); 72 bos.reset(); 73 return; 74 } 75 76 bos.write( b ); 77 } 78 79 85 public void flush() throws IOException  86 { 87 final byte[] content = bos.toByteArray(); 88 logMessage( new String ( content ) ); 89 bos.reset(); 90 } 91 92 99 public void close() throws IOException  100 { 101 flush(); 102 } 103 104 110 protected abstract void logMessage( String message ); 111 112 113 private final ByteArrayOutputStream bos = new ByteArrayOutputStream (); 114 115 116 protected final Logger m_logger; 117 }
| Popular Tags
|