[jboss-cvs] jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging ...
Max Rydahl Andersen
mandersen at jboss.com
Mon Dec 11 17:22:01 EST 2006
User: mandersen
Date: 06/12/11 17:22:01
Modified: hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging
PluginLogAppender.java
Added: hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging
CurrentContext.java
Log:
HBX-830 Database errors should not be displayed in Log Error view
HBX-837 Have seperate logs per configuration
Revision Changes Path
1.4 +35 -5 jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginLogAppender.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PluginLogAppender.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginLogAppender.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- PluginLogAppender.java 7 Jul 2006 13:50:57 -0000 1.3
+++ PluginLogAppender.java 11 Dec 2006 22:22:01 -0000 1.4
@@ -21,6 +21,13 @@
*/
package org.hibernate.eclipse.logging;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Level;
import org.apache.log4j.Priority;
@@ -30,6 +37,12 @@
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+import org.hibernate.console.KnownConfigurations;
/**
* PluginLogAppender
@@ -40,6 +53,8 @@
public class PluginLogAppender extends AppenderSkeleton {
private ILog pluginLog;
+ private Map streams = new HashMap();
+
/**
* Sets the Eclipse log instance
@@ -74,7 +89,7 @@
if (info != null)
thrown = info.getThrowable();
}
-
+ /*
Level level = event.getLevel();
int severity = IStatus.OK;
@@ -87,10 +102,25 @@
if (level.toInt() >= Priority.DEBUG_INT)
severity = IStatus.INFO;
+
this.pluginLog.log(new Status(severity,
this.pluginLog.getBundle().getSymbolicName(),
- level.toInt(),text,thrown));
+ level.toInt(),text,thrown));*/
+
+ Object peek = CurrentContext.peek();
+ MessageConsoleStream stream = KnownConfigurations.getInstance().findLoggingStream( (String)peek );
+ if(stream!=null) {
+ stream.println(text);
+ if(thrown!=null) {
+ StringWriter stringWriter = new StringWriter();
+ thrown.printStackTrace( new PrintWriter(stringWriter) );
+ stream.println(stringWriter.getBuffer().toString());
}
+ }
+
+ }
+
+
/**
* Closes this appender
1.1 date: 2006/12/11 22:22:01; author: mandersen; state: Exp;jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/CurrentContext.java
Index: CurrentContext.java
===================================================================
package org.hibernate.eclipse.logging;
import java.util.Hashtable;
import java.util.Stack;
/**
* CurrentContext is here to have one place where we can keep track on the
* "current" console configuration to allow logging to be seperated per config.
*
*/
public class CurrentContext {
static Hashtable map = new Hashtable();
private CurrentContext() {
}
public static int getDepth() {
Stack stack = (Stack) map.get( Thread.currentThread() );
if ( stack == null )
return 0;
else
return stack.size();
}
public static Object pop() {
Thread key = Thread.currentThread();
Stack stack = (Stack) map.get( key );
if ( stack != null && !stack.isEmpty() )
return (stack.pop() );
else
return null;
}
public static Object peek() {
Thread key = Thread.currentThread();
Stack stack = (Stack) map.get( key );
if ( stack != null && !stack.isEmpty() )
return stack.peek();
else
return null;
}
public static void push(Object message) {
Thread key = Thread.currentThread();
Stack stack = (Stack) map.get( key );
if ( stack == null ) {
stack = new Stack();
map.put( key, stack );
stack.push( message );
}
else if ( stack.isEmpty() ) {
stack.push( message );
}
else {
stack.push( message );
}
}
static public void remove() {
map.remove( Thread.currentThread() );
}
}
More information about the jboss-cvs-commits
mailing list