Merging code from trunk that fixes #774, this work was done by incastrix
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / LogProxy.java
1 package com.quantum.view;
2
3 import java.io.PrintWriter;
4 import java.io.StringWriter;
5
6 public class LogProxy implements LogConstants {
7         private static LogProxy instance = null;
8         private SQLLogView log = null;
9         private LogProxy() {
10         }
11         public synchronized static LogProxy getInstance() {
12                 if (instance == null) {
13                         instance = new LogProxy();
14                 }
15                 return instance;
16         }
17         public void addText(int type, String text) {
18                 log = SQLLogView.getInstance();
19                 if (log != null) {
20                         log.addText(type, text);
21                 }
22         }
23
24     public void addText(int type, String text, Exception e) {
25         addText(type, text);
26         StringWriter writer = new StringWriter();
27         e.printStackTrace(new PrintWriter(writer));
28         addText(type, writer.toString());
29     }
30
31     public void addText(int type, Exception e) {
32         addText(type, "Error occured: " + e, e); //$NON-NLS-1$
33     }
34 }