[logback-dev] svn commit: r2044 - in logback-incubator/trunk/logback-as400/src/main/java/ch: . qos qos/logback qos/logback/as400 qos/logback/as400/io qos/logback/as400/print

noreply.ravn at qos.ch noreply.ravn at qos.ch
Mon Dec 1 14:10:37 CET 2008


Author: ravn
Date: Mon Dec  1 14:03:23 2008
New Revision: 2044

Added:
   logback-incubator/trunk/logback-as400/src/main/java/ch/
   logback-incubator/trunk/logback-as400/src/main/java/ch/qos/
   logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/
   logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/as400/
   logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/as400/io/
   logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/as400/io/FixedWidthPrintStream.java
   logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/as400/print/
   logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/as400/print/QPrintAppender.java

Log:
initial skeletons for QPrintAppender

Added: logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/as400/io/FixedWidthPrintStream.java
==============================================================================
--- (empty file)
+++ logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/as400/io/FixedWidthPrintStream.java	Mon Dec  1 14:03:23 2008
@@ -0,0 +1,85 @@
+package ch.qos.logback.as400.io;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+/**
+ * FixedWidthPrintStream is a stream wrapper which ensures that the output does
+ * not get wider than the specified number of columns.  
+ * 
+ */
+public class FixedWidthPrintStream {
+
+	protected static final int BEFORE_COLUMN_ZERO = -1;
+
+	private String indent = "  +";
+	private int wrapColumn = 79;
+	private PrintStream originalStream;
+
+	private PrintStream thisStream;
+	/** 
+	 * @param originalStream
+	 * @param wrapColumn - first column is column 0.
+	 * @param indent
+	 */
+
+	public PrintStream getStream() {
+		if (thisStream == null) {
+			thisStream = new PrintStream(new OutputStream() {
+
+				// Next char will go in 0
+				int currentColumn = BEFORE_COLUMN_ZERO;
+
+				public void write(int b) {
+					originalStream.write(b);
+					currentColumn = currentColumn + 1;
+
+					if (b == '\n') {
+						currentColumn = BEFORE_COLUMN_ZERO;
+					} else if (currentColumn >= wrapColumn) {
+						originalStream.write('\n');
+						currentColumn = BEFORE_COLUMN_ZERO;
+						for (int i = 0; i < indent.length(); i++) {
+							originalStream.write(indent.charAt(i));
+							currentColumn = currentColumn + 1;
+						}
+					}
+				}
+
+				public void close() {
+					originalStream.close();
+				}
+
+				public void flush() {
+					originalStream.flush();
+				}
+			});
+		}
+		return thisStream;
+	}
+
+	public int getWrapColumn() {
+		return wrapColumn;
+	}
+
+	public void setWrapColumn(int wrapColumn) {
+		this.wrapColumn = wrapColumn;
+	}
+
+	public PrintStream getOriginalStream() {
+		return originalStream;
+	}
+
+	public void setOriginalStream(PrintStream wrappedStream) {
+		this.originalStream = wrappedStream;
+	}
+
+	public String getIndent() {
+		return indent;
+	}
+
+	public void setIndent(String indent) {
+		this.indent = indent;
+	}
+
+}

Added: logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/as400/print/QPrintAppender.java
==============================================================================
--- (empty file)
+++ logback-incubator/trunk/logback-as400/src/main/java/ch/qos/logback/as400/print/QPrintAppender.java	Mon Dec  1 14:03:23 2008
@@ -0,0 +1,20 @@
+package ch.qos.logback.as400.print;
+
+import ch.qos.logback.core.AppenderBase;
+
+/**
+ * 
+ *
+ */
+public class QPrintAppender extends AppenderBase {
+
+
+	
+	@Override
+	protected void append(Object arg0) {
+		
+	}
+	
+	
+
+}


More information about the logback-dev mailing list