Public Member Functions | |
LoggingOutputStream (Category cat, Priority priority) throws IllegalArgumentException | |
void | close () |
void | write (final int b) throws IOException |
void | flush () |
Static Public Attributes | |
final int | DEFAULT_BUFFER_LENGTH = 2048 |
Protected Attributes | |
boolean | hasBeenClosed = false |
byte[] | buf |
int | count |
Category | category |
Priority | priority |
Static Protected Attributes | |
final String | LINE_SEPERATOR |
Note that no data is written out to the Category until the stream is flushed or closed.
Definition at line 45 of file LoggingOutputStream.java.
|
Creates the LoggingOutputStream to flush to the given Category.
Definition at line 92 of file LoggingOutputStream.java. References org.objectweb.cjdbc.common.util.LoggingOutputStream.buf, org.objectweb.cjdbc.common.util.LoggingOutputStream.category, org.objectweb.cjdbc.common.util.LoggingOutputStream.count, and org.objectweb.cjdbc.common.util.LoggingOutputStream.priority. 00094 { 00095 if (cat == null) 00096 { 00097 throw new IllegalArgumentException("cat == null"); 00098 } 00099 if (priority == null) 00100 { 00101 throw new IllegalArgumentException("priority == null"); 00102 } 00103 this.priority = priority; 00104 category = cat; 00105 bufLength = DEFAULT_BUFFER_LENGTH; 00106 buf = new byte[DEFAULT_BUFFER_LENGTH]; 00107 count = 0; 00108 }
|
|
Closes this output stream and releases any system resources associated with this stream. The general contract of Definition at line 116 of file LoggingOutputStream.java. References org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), and org.objectweb.cjdbc.common.util.LoggingOutputStream.hasBeenClosed. 00117 { 00118 flush(); 00119 hasBeenClosed = true; 00120 }
|
|
Flushes this output stream and forces any buffered output bytes to be written out. The general contract of Definition at line 164 of file LoggingOutputStream.java. References org.objectweb.cjdbc.common.util.LoggingOutputStream.buf, org.objectweb.cjdbc.common.util.LoggingOutputStream.category, org.objectweb.cjdbc.common.util.LoggingOutputStream.count, and org.objectweb.cjdbc.common.util.LoggingOutputStream.priority. Referenced by org.objectweb.cjdbc.common.util.LoggingOutputStream.close(). 00165 { 00166 if (count == 0) 00167 { 00168 return; 00169 } 00170 // don't print out blank lines; flushing from PrintStream puts out these 00171 if (count == LINE_SEPERATOR.length()) 00172 { 00173 if (((char) buf[0]) == LINE_SEPERATOR.charAt(0) && ((count == 1) || // <- 00174 // Unix 00175 // & 00176 // Mac, 00177 // -> 00178 // Windows 00179 ((count == 2) && ((char) buf[1]) == LINE_SEPERATOR.charAt(1)))) 00180 { 00181 reset(); 00182 return; 00183 } 00184 } 00185 final byte[] theBytes = new byte[count]; 00186 System.arraycopy(buf, 0, theBytes, 0, count); 00187 00188 // ADDED: We don't want blank lines at all 00189 String bytes = new String(theBytes).trim(); 00190 int line = -1; 00191 while((line = bytes.indexOf(LINE_SEPERATOR))!=-1) 00192 { 00193 bytes = bytes.substring(0, line) + bytes.substring(line+LINE_SEPERATOR.length()); 00194 } 00195 // END ADDED 00196 00197 category.log(priority, bytes); 00198 reset(); 00199 }
|
|
Writes the specified byte to this output stream. The general contract for
Definition at line 132 of file LoggingOutputStream.java. References org.objectweb.cjdbc.common.util.LoggingOutputStream.buf, and org.objectweb.cjdbc.common.util.LoggingOutputStream.count. 00133 { 00134 if (hasBeenClosed) 00135 { 00136 throw new IOException("The stream has been closed."); 00137 } 00138 // don't log nulls 00139 if (b == 0) 00140 { 00141 return; 00142 } 00143 // would this be writing past the buffer? 00144 if (count == bufLength) 00145 { 00146 // grow the buffer 00147 final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH; 00148 final byte[] newBuf = new byte[newBufLength]; 00149 System.arraycopy(buf, 0, newBuf, 0, bufLength); 00150 buf = newBuf; 00151 bufLength = newBufLength; 00152 } 00153 buf[count] = (byte) b; 00154 count++; 00155 }
|
|
The internal buffer where data is stored. Definition at line 56 of file LoggingOutputStream.java. Referenced by org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream(), and org.objectweb.cjdbc.common.util.LoggingOutputStream.write(). |
|
The category to write to. Definition at line 74 of file LoggingOutputStream.java. Referenced by org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), and org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream(). |
|
The number of valid bytes in the buffer. This value is always in the range Definition at line 62 of file LoggingOutputStream.java. Referenced by org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream(), and org.objectweb.cjdbc.common.util.LoggingOutputStream.write(). |
|
The default number of bytes in the buffer. =2048 Definition at line 70 of file LoggingOutputStream.java. |
|
Used to maintain the contract of close(). Definition at line 52 of file LoggingOutputStream.java. Referenced by org.objectweb.cjdbc.common.util.LoggingOutputStream.close(). |
|
Initial value: System
.getProperty("line.separator")
Definition at line 47 of file LoggingOutputStream.java. |
|
The priority to use when writing to the Category. Definition at line 78 of file LoggingOutputStream.java. Referenced by org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), and org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream(). |