1 64 65 package com.jcorporate.expresso.core.servlet; 66 67 68 import com.jcorporate.expresso.kernel.InstallLog; 69 import org.apache.log4j.Logger; 70 71 import java.io.ByteArrayOutputStream ; 72 import java.io.IOException ; 73 import java.io.PrintStream ; 74 import java.io.PrintWriter ; 75 76 85 public class ServletInstallLog implements InstallLog { 86 87 88 private static final transient Logger log = Logger.getLogger(ServletInstallLog.class); 89 90 private PrintWriter out; 91 92 93 99 public ServletInstallLog(PrintWriter theOutputStream) throws IOException { 100 out = theOutputStream; 101 } 102 103 106 protected ServletInstallLog() { 107 108 } 109 110 111 116 public void debug(String message) { 117 out.println("<p><font color=\"green\"> [DEBUG] " + message + "</font></p>"); 118 } 119 120 121 126 public void info(String message) { 127 out.println("<p align=\"center\">" + message + "</p>"); 128 } 129 130 135 public void warn(String message) { 136 out.println("<p align=\"center\"><font color=\"orange\"> [WARN] " + message + "</font></p>"); 137 } 138 139 145 public void warn(String message, Throwable error) { 146 out.println("<p align=\"center\"><font color=\"orange\"> [WARN] " + message + "</font></p>"); 147 writeException(error); 148 } 149 150 156 public void error(String message, Throwable error) { 157 out.println("<p align=\"center\"><font color=\"red\"> [WARN] " + message + "</font></p>"); 158 writeException(error); 159 } 160 161 166 public void error(String message) { 167 out.println("<p align=\"center\"><font color=\"red\"> [WARN] " + message + "</font></p>"); 168 } 169 170 171 177 protected void writeException(Throwable error) { 178 out.println("<p align=\"center\">" + error.getMessage() + "</p>"); 179 out.println("<blockquote>"); 180 ByteArrayOutputStream bos = new ByteArrayOutputStream (); 181 error.printStackTrace(new PrintStream (bos)); 182 out.println(bos.toString()); 183 out.println("</blockquote>"); 184 } 185 186 } | Popular Tags |