1 43 44 package org.jfree.util; 45 46 import java.io.PrintStream ; 47 import java.io.Serializable ; 48 49 54 public class PrintStreamLogTarget implements LogTarget, Serializable { 55 56 57 private static final long serialVersionUID = 6510564403264504688L; 58 59 60 private PrintStream printStream; 61 62 69 public PrintStreamLogTarget() { 70 this (System.out); 71 } 72 73 78 public PrintStreamLogTarget(final PrintStream printStream) { 79 if (printStream == null) { 80 throw new NullPointerException (); 81 } 82 this.printStream = printStream; 83 } 84 85 93 public void log(int level, final Object message) { 94 if (level > 3) { 95 level = 3; 96 } 97 this.printStream.print(LEVELS[level]); 98 this.printStream.println(message); 99 if (level < 3) { 100 System.out.flush(); 101 } 102 } 103 104 115 public void log(int level, final Object message, final Exception e) { 116 if (level > 3) { 117 level = 3; 118 } 119 this.printStream.print(LEVELS[level]); 120 this.printStream.println(message); 121 e.printStackTrace(this.printStream); 122 if (level < 3) { 123 System.out.flush(); 124 } 125 } 126 } 127 | Popular Tags |