Author: tom.baeyens(a)jboss.com
Date: 2008-10-31 06:49:02 -0400 (Fri, 31 Oct 2008)
New Revision: 2702
Added:
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14Log.java
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14LogFactory.java
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log.java
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLog.java
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLogFactory.java
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFactory.java
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFormatter.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14Log.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14LogFactory.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLog.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLogFactory.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFactory.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFormatter.java
Modified:
jbpm4/trunk/modules/log/
jbpm4/trunk/modules/log/pom.xml
jbpm4/trunk/modules/test/pom.xml
Log:
unification api proposals
Property changes on: jbpm4/trunk/modules/log
___________________________________________________________________
Name: svn:ignore
+ target
Modified: jbpm4/trunk/modules/log/pom.xml
===================================================================
--- jbpm4/trunk/modules/log/pom.xml 2008-10-31 10:28:46 UTC (rev 2701)
+++ jbpm4/trunk/modules/log/pom.xml 2008-10-31 10:49:02 UTC (rev 2702)
@@ -27,6 +27,10 @@
<!-- Dependencies -->
<dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
</dependencies>
<!-- Plugins -->
Copied: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java
(from rev 2701,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java)
===================================================================
--- jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java
(rev 0)
+++
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java 2008-10-31
10:49:02 UTC (rev 2702)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.log;
+
+import java.io.IOException;
+import java.util.logging.FileHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.MemoryHandler;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ErrorTriggeredFileHandler extends Handler {
+
+ private static final int DEFAULT_SIZE = 500;
+ private static final Level DEFAULT_PUSH_LEVEL = Level.SEVERE;
+ private static final String DEFAULT_PATTERN = "%h/jbpm%u.log";
+
+ DecoratedMemoryHandler memoryHandler = null;
+ FileHandler fileHandler = null;
+
+ public ErrorTriggeredFileHandler() throws SecurityException, IOException {
+ fileHandler = getConfiguredTarget();
+ memoryHandler = new DecoratedMemoryHandler(fileHandler, getConfiguredSize(),
getConfiguredPushLevel());
+ }
+
+ private static Level getConfiguredPushLevel() {
+ LogManager manager = LogManager.getLogManager();
+ String pushLevelText = manager.getProperty(ErrorTriggeredFileHandler.class.getName()
+ ".push");
+ if (pushLevelText == null) {
+ return DEFAULT_PUSH_LEVEL;
+ }
+ try {
+ return Level.parse(pushLevelText.trim());
+ } catch (Exception ex) {
+ return DEFAULT_PUSH_LEVEL;
+ }
+ }
+
+ protected static int getConfiguredSize() {
+ LogManager manager = LogManager.getLogManager();
+ String sizeText = manager.getProperty(ErrorTriggeredFileHandler.class.getName() +
".size");
+ if (sizeText == null) {
+ return DEFAULT_SIZE;
+ }
+ try {
+ return Integer.parseInt(sizeText.trim());
+ } catch (Exception ex) {
+ return DEFAULT_SIZE;
+ }
+ }
+
+ protected static FileHandler getConfiguredTarget() throws SecurityException,
IOException {
+ LogManager manager = LogManager.getLogManager();
+ String pattern = manager.getProperty(ErrorTriggeredFileHandler.class.getName() +
".pattern");
+ if (pattern == null) {
+ pattern = DEFAULT_PATTERN;
+ }
+ return new FileHandler(pattern);
+ }
+
+
+ public class DecoratedMemoryHandler extends MemoryHandler {
+ public DecoratedMemoryHandler(FileHandler target, int size, Level pushLevel) {
+ super(target, size, pushLevel);
+ }
+ public void push() {
+ fileHandler.setFormatter(new LogFormatter());
+ super.push();
+ LogRecord emptyLine = new LogRecord(Level.INFO, "");
+ emptyLine.setLoggerName("");
+ fileHandler.publish(emptyLine);
+ LogRecord line = new LogRecord(Level.INFO, "---- END OF TRIGGERED PUSH
---------------------------------------------------");
+ line.setLoggerName("");
+ fileHandler.publish(line);
+ fileHandler.publish(emptyLine);
+ fileHandler.publish(emptyLine);
+ }
+ }
+
+ public void close() throws SecurityException {
+ memoryHandler.close();
+ }
+
+ public void flush() {
+ memoryHandler.flush();
+ }
+
+ public void publish(LogRecord record) {
+ memoryHandler.publish(record);
+ }
+}
Property changes on:
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14Log.java (from rev 2701,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14Log.java)
===================================================================
--- jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14Log.java
(rev 0)
+++ jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14Log.java 2008-10-31 10:49:02
UTC (rev 2702)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.log;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jbpm.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Jdk14Log extends Log {
+
+ Logger log;
+
+ public Jdk14Log(Logger logger) {
+ this.log = logger;
+ }
+
+ public void error(String msg) {
+ log.log(Level.SEVERE, msg);
+ }
+
+ public void error(String msg, Throwable exception) {
+ log.log(Level.SEVERE, msg, exception);
+ }
+
+ public boolean isInfoEnabled() {
+ return log.isLoggable(Level.INFO);
+ }
+
+ public void info(String msg) {
+ log.log(Level.INFO, msg);
+ }
+
+ public void info(String msg, Throwable exception) {
+ log.log(Level.INFO, msg, exception);
+ }
+
+ public boolean isDebugEnabled() {
+ return log.isLoggable(Level.FINE);
+ }
+
+ public void debug(String msg) {
+ log.log(Level.FINE, msg);
+ }
+
+ public void debug(String msg, Throwable exception) {
+ log.log(Level.FINE, msg, exception);
+ }
+
+ public boolean isTraceEnabled() {
+ return log.isLoggable(Level.FINEST);
+ }
+
+ public void trace(String msg) {
+ log.log(Level.FINEST, msg);
+ }
+
+ public void trace(String msg, Throwable exception) {
+ log.log(Level.FINEST, msg, exception);
+ }
+}
Property changes on: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14Log.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14LogFactory.java (from rev
2701, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14LogFactory.java)
===================================================================
--- jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14LogFactory.java
(rev 0)
+++ jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14LogFactory.java 2008-10-31
10:49:02 UTC (rev 2702)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.log;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+import org.jbpm.PvmException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Jdk14LogFactory implements LogFactory {
+
+ public Jdk14LogFactory() {
+ initializeJdk14Logging();
+ }
+
+ public Log getLog(String name) {
+ return new Jdk14Log(Logger.getLogger(name));
+ }
+
+ /** redirects commons logging to JDK 1.4 logging. This can be handy when
+ * you have log4j on the classpath, but still want to use the JDK logging. */
+ public static synchronized void redirectCommonsToJdk14() {
+ System.setProperty("org.apache.commons.logging.Log",
+ "org.apache.commons.logging.impl.Jdk14Logger" );
+ }
+
+ /** configures JDK 1.4 logging from the resource file
<code>logging.properties</code> */
+ public static synchronized void initializeJdk14Logging() {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream inputStream =
classLoader.getResourceAsStream("logging.properties");
+ try {
+ if (inputStream != null) {
+ LogManager.getLogManager().readConfiguration(inputStream);
+ }
+
+ String redirectCommons =
LogManager.getLogManager().getProperty("redirect.commons.logging");
+ if ( (redirectCommons!=null)
+ && (! redirectCommons.equalsIgnoreCase("disabled"))
+ && (! redirectCommons.equalsIgnoreCase("off"))
+ && (! redirectCommons.equalsIgnoreCase("false"))
+ ) {
+ redirectCommonsToJdk14();
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("couldn't initialize logging properly",
e);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
Property changes on:
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Jdk14LogFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log.java (from rev 2701,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log.java)
===================================================================
--- jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log.java
(rev 0)
+++ jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log.java 2008-10-31 10:49:02 UTC
(rev 2702)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class Log {
+
+ static LogFactory logFactory;
+
+ public static synchronized Log getLog(String name) {
+ if (logFactory==null) {
+
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ // if logging.properties is available on the classpath
+ if (classLoader.getResource("logging.properties")!=null) {
+ logFactory = new Jdk14LogFactory();
+
+ // if log4j is available on the classpath
+ } else if (isLog4jAvailable(classLoader)) {
+ logFactory = new Log4jLogFactory();
+
+ } else {
+ logFactory = new Jdk14LogFactory();
+
+ }
+ }
+ return logFactory.getLog(name);
+ }
+
+ static boolean isLog4jAvailable(ClassLoader classLoader) {
+ try {
+ classLoader.loadClass("org.apache.log4j.LogManager");
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+
+ public abstract void error(String msg);
+ public abstract void error(String msg, Throwable exception);
+
+ public abstract boolean isInfoEnabled();
+ public abstract void info(String msg);
+ public abstract void info(String msg, Throwable exception);
+
+ public abstract boolean isDebugEnabled();
+ public abstract void debug(String msg);
+ public abstract void debug(String msg, Throwable exception);
+
+ public abstract boolean isTraceEnabled();
+ public abstract void trace(String msg);
+ public abstract void trace(String msg, Throwable exception);
+}
Property changes on: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLog.java (from rev 2701,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLog.java)
===================================================================
--- jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLog.java
(rev 0)
+++ jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLog.java 2008-10-31 10:49:02
UTC (rev 2702)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.log;
+
+/**
+ * @author Tom Baeyens
+ */
+public class Log4jLog extends Log {
+
+ org.apache.log4j.Logger log;
+
+ public Log4jLog(org.apache.log4j.Logger log) {
+ this.log = log;
+ }
+
+ public void error(String msg) {
+ log.error(msg);
+ }
+
+ public void error(String msg, Throwable exception) {
+ log.error(msg, exception);
+ }
+
+ public boolean isInfoEnabled() {
+ return log.isInfoEnabled();
+ }
+
+ public void info(String msg) {
+ log.info(msg);
+ }
+
+ public void info(String msg, Throwable exception) {
+ log.info(msg, exception);
+ }
+
+ public boolean isDebugEnabled() {
+ return log.isDebugEnabled();
+ }
+
+ public void debug(String msg) {
+ log.debug(msg);
+ }
+
+ public void debug(String msg, Throwable exception) {
+ log.debug(msg, exception);
+ }
+
+ public boolean isTraceEnabled() {
+ return log.isTraceEnabled();
+ }
+
+ public void trace(String msg) {
+ log.trace(msg);
+ }
+
+ public void trace(String msg, Throwable exception) {
+ log.trace(msg, exception);
+ }
+}
Property changes on: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLog.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLogFactory.java (from rev
2701, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLogFactory.java)
===================================================================
--- jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLogFactory.java
(rev 0)
+++ jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLogFactory.java 2008-10-31
10:49:02 UTC (rev 2702)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.log;
+
+import org.apache.log4j.LogManager;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Log4jLogFactory implements LogFactory {
+
+ public Log getLog(String name) {
+ return new Log4jLog(LogManager.getLogger(name));
+ }
+
+}
Property changes on:
jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/Log4jLogFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFactory.java (from rev 2701,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFactory.java)
===================================================================
--- jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFactory.java
(rev 0)
+++ jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFactory.java 2008-10-31 10:49:02
UTC (rev 2702)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface LogFactory {
+
+ Log getLog(String name);
+
+}
Property changes on: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFormatter.java (from rev
2701, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFormatter.java)
===================================================================
--- jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFormatter.java
(rev 0)
+++ jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFormatter.java 2008-10-31
10:49:02 UTC (rev 2702)
@@ -0,0 +1,81 @@
+package org.jbpm.log;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+import org.jbpm.pvm.internal.util.ReflectUtil;
+
+public class LogFormatter extends Formatter {
+
+ static final String NEWLINE = System.getProperty("line.separator");
+ static final DateFormat dateTimeFormat = new
SimpleDateFormat("HH:mm:ss,SSS");
+ static final Map<Level, String> levels = new HashMap<Level, String>();
+ private static Map<Integer, Integer> indentations = new HashMap<Integer,
Integer>();
+
+
+ static {
+ levels.put(Level.ALL, "ALL");
+ levels.put(Level.CONFIG, "CFG");
+ levels.put(Level.FINE, "FIN");
+ levels.put(Level.FINER, "FNR");
+ levels.put(Level.FINEST, "FST");
+ levels.put(Level.INFO, "INF");
+ levels.put(Level.OFF, "OFF");
+ levels.put(Level.SEVERE, "SEV");
+ levels.put(Level.WARNING, "WRN");
+ }
+
+ public String format(LogRecord logRecord) {
+ StringWriter msg = new StringWriter();
+ if (logRecord.getThrown()!=null) {
+ msg.append("### EXCEPTION ###########################################");
+ msg.append(NEWLINE);
+ }
+ msg.append(dateTimeFormat.format(new Date()));
+ msg.append(" ");
+ msg.append(levels.get(logRecord.getLevel()));
+ msg.append(" ");
+
+ int threadId = logRecord.getThreadID();
+ for (int i=0; i<getIndentation(threadId); i++) {
+ msg.append(" ");
+ }
+
+ msg.append("| [");
+
+ String loggerName = logRecord.getLoggerName();
+ msg.append(ReflectUtil.getUnqualifiedClassName(loggerName));
+
+ msg.append("] ");
+
+ msg.append(logRecord.getMessage());
+ if (logRecord.getThrown()!=null) {
+ msg.append(NEWLINE);
+ logRecord.getThrown().printStackTrace(new PrintWriter(msg));
+ msg.append("### EXCEPTION ###########################################");
+ }
+ msg.append(NEWLINE);
+ return msg.toString();
+ }
+
+ private int getIndentation(int threadId) {
+ Integer indentation = indentations.get(threadId);
+ if (indentation==null) {
+ indentation = indentations.size();
+ indentations.put(threadId, indentation);
+ }
+ return indentation;
+ }
+
+ public static void resetIndentation() {
+ indentations = new HashMap<Integer, Integer>();
+ }
+}
Property changes on: jbpm4/trunk/modules/log/src/main/java/org/jbpm/log/LogFormatter.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java 2008-10-31
10:28:46 UTC (rev 2701)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/ErrorTriggeredFileHandler.java 2008-10-31
10:49:02 UTC (rev 2702)
@@ -1,115 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.log;
-
-import java.io.IOException;
-import java.util.logging.FileHandler;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogManager;
-import java.util.logging.LogRecord;
-import java.util.logging.MemoryHandler;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ErrorTriggeredFileHandler extends Handler {
-
- private static final int DEFAULT_SIZE = 500;
- private static final Level DEFAULT_PUSH_LEVEL = Level.SEVERE;
- private static final String DEFAULT_PATTERN = "%h/jbpm%u.log";
-
- DecoratedMemoryHandler memoryHandler = null;
- FileHandler fileHandler = null;
-
- public ErrorTriggeredFileHandler() throws SecurityException, IOException {
- fileHandler = getConfiguredTarget();
- memoryHandler = new DecoratedMemoryHandler(fileHandler, getConfiguredSize(),
getConfiguredPushLevel());
- }
-
- private static Level getConfiguredPushLevel() {
- LogManager manager = LogManager.getLogManager();
- String pushLevelText = manager.getProperty(ErrorTriggeredFileHandler.class.getName()
+ ".push");
- if (pushLevelText == null) {
- return DEFAULT_PUSH_LEVEL;
- }
- try {
- return Level.parse(pushLevelText.trim());
- } catch (Exception ex) {
- return DEFAULT_PUSH_LEVEL;
- }
- }
-
- protected static int getConfiguredSize() {
- LogManager manager = LogManager.getLogManager();
- String sizeText = manager.getProperty(ErrorTriggeredFileHandler.class.getName() +
".size");
- if (sizeText == null) {
- return DEFAULT_SIZE;
- }
- try {
- return Integer.parseInt(sizeText.trim());
- } catch (Exception ex) {
- return DEFAULT_SIZE;
- }
- }
-
- protected static FileHandler getConfiguredTarget() throws SecurityException,
IOException {
- LogManager manager = LogManager.getLogManager();
- String pattern = manager.getProperty(ErrorTriggeredFileHandler.class.getName() +
".pattern");
- if (pattern == null) {
- pattern = DEFAULT_PATTERN;
- }
- return new FileHandler(pattern);
- }
-
-
- public class DecoratedMemoryHandler extends MemoryHandler {
- public DecoratedMemoryHandler(FileHandler target, int size, Level pushLevel) {
- super(target, size, pushLevel);
- }
- public void push() {
- fileHandler.setFormatter(new LogFormatter());
- super.push();
- LogRecord emptyLine = new LogRecord(Level.INFO, "");
- emptyLine.setLoggerName("");
- fileHandler.publish(emptyLine);
- LogRecord line = new LogRecord(Level.INFO, "---- END OF TRIGGERED PUSH
---------------------------------------------------");
- line.setLoggerName("");
- fileHandler.publish(line);
- fileHandler.publish(emptyLine);
- fileHandler.publish(emptyLine);
- }
- }
-
- public void close() throws SecurityException {
- memoryHandler.close();
- }
-
- public void flush() {
- memoryHandler.flush();
- }
-
- public void publish(LogRecord record) {
- memoryHandler.publish(record);
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14Log.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14Log.java 2008-10-31 10:28:46
UTC (rev 2701)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14Log.java 2008-10-31 10:49:02
UTC (rev 2702)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.log;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.jbpm.log.Log;
-
-
-/**
- * @author Tom Baeyens
- */
-public class Jdk14Log extends Log {
-
- Logger log;
-
- public Jdk14Log(Logger logger) {
- this.log = logger;
- }
-
- public void error(String msg) {
- log.log(Level.SEVERE, msg);
- }
-
- public void error(String msg, Throwable exception) {
- log.log(Level.SEVERE, msg, exception);
- }
-
- public boolean isInfoEnabled() {
- return log.isLoggable(Level.INFO);
- }
-
- public void info(String msg) {
- log.log(Level.INFO, msg);
- }
-
- public void info(String msg, Throwable exception) {
- log.log(Level.INFO, msg, exception);
- }
-
- public boolean isDebugEnabled() {
- return log.isLoggable(Level.FINE);
- }
-
- public void debug(String msg) {
- log.log(Level.FINE, msg);
- }
-
- public void debug(String msg, Throwable exception) {
- log.log(Level.FINE, msg, exception);
- }
-
- public boolean isTraceEnabled() {
- return log.isLoggable(Level.FINEST);
- }
-
- public void trace(String msg) {
- log.log(Level.FINEST, msg);
- }
-
- public void trace(String msg, Throwable exception) {
- log.log(Level.FINEST, msg, exception);
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14LogFactory.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14LogFactory.java 2008-10-31
10:28:46 UTC (rev 2701)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Jdk14LogFactory.java 2008-10-31
10:49:02 UTC (rev 2702)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.log;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.logging.LogManager;
-import java.util.logging.Logger;
-
-import org.jbpm.PvmException;
-
-
-/**
- * @author Tom Baeyens
- */
-public class Jdk14LogFactory implements LogFactory {
-
- public Jdk14LogFactory() {
- initializeJdk14Logging();
- }
-
- public Log getLog(String name) {
- return new Jdk14Log(Logger.getLogger(name));
- }
-
- /** redirects commons logging to JDK 1.4 logging. This can be handy when
- * you have log4j on the classpath, but still want to use the JDK logging. */
- public static synchronized void redirectCommonsToJdk14() {
- System.setProperty("org.apache.commons.logging.Log",
- "org.apache.commons.logging.impl.Jdk14Logger" );
- }
-
- /** configures JDK 1.4 logging from the resource file
<code>logging.properties</code> */
- public static synchronized void initializeJdk14Logging() {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- InputStream inputStream =
classLoader.getResourceAsStream("logging.properties");
- try {
- if (inputStream != null) {
- LogManager.getLogManager().readConfiguration(inputStream);
- }
-
- String redirectCommons =
LogManager.getLogManager().getProperty("redirect.commons.logging");
- if ( (redirectCommons!=null)
- && (! redirectCommons.equalsIgnoreCase("disabled"))
- && (! redirectCommons.equalsIgnoreCase("off"))
- && (! redirectCommons.equalsIgnoreCase("false"))
- ) {
- redirectCommonsToJdk14();
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- throw new PvmException("couldn't initialize logging properly", e);
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log.java 2008-10-31 10:28:46 UTC
(rev 2701)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log.java 2008-10-31 10:49:02 UTC
(rev 2702)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.log;
-
-
-/**
- * @author Tom Baeyens
- */
-public abstract class Log {
-
- static LogFactory logFactory;
-
- public static synchronized Log getLog(String name) {
- if (logFactory==null) {
-
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- // if logging.properties is available on the classpath
- if (classLoader.getResource("logging.properties")!=null) {
- logFactory = new Jdk14LogFactory();
-
- // if log4j is available on the classpath
- } else if (isLog4jAvailable(classLoader)) {
- logFactory = new Log4jLogFactory();
-
- } else {
- logFactory = new Jdk14LogFactory();
-
- }
- }
- return logFactory.getLog(name);
- }
-
- static boolean isLog4jAvailable(ClassLoader classLoader) {
- try {
- classLoader.loadClass("org.apache.log4j.LogManager");
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
-
- public abstract void error(String msg);
- public abstract void error(String msg, Throwable exception);
-
- public abstract boolean isInfoEnabled();
- public abstract void info(String msg);
- public abstract void info(String msg, Throwable exception);
-
- public abstract boolean isDebugEnabled();
- public abstract void debug(String msg);
- public abstract void debug(String msg, Throwable exception);
-
- public abstract boolean isTraceEnabled();
- public abstract void trace(String msg);
- public abstract void trace(String msg, Throwable exception);
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLog.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLog.java 2008-10-31 10:28:46
UTC (rev 2701)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLog.java 2008-10-31 10:49:02
UTC (rev 2702)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.log;
-
-/**
- * @author Tom Baeyens
- */
-public class Log4jLog extends Log {
-
- org.apache.log4j.Logger log;
-
- public Log4jLog(org.apache.log4j.Logger log) {
- this.log = log;
- }
-
- public void error(String msg) {
- log.error(msg);
- }
-
- public void error(String msg, Throwable exception) {
- log.error(msg, exception);
- }
-
- public boolean isInfoEnabled() {
- return log.isInfoEnabled();
- }
-
- public void info(String msg) {
- log.info(msg);
- }
-
- public void info(String msg, Throwable exception) {
- log.info(msg, exception);
- }
-
- public boolean isDebugEnabled() {
- return log.isDebugEnabled();
- }
-
- public void debug(String msg) {
- log.debug(msg);
- }
-
- public void debug(String msg, Throwable exception) {
- log.debug(msg, exception);
- }
-
- public boolean isTraceEnabled() {
- return log.isTraceEnabled();
- }
-
- public void trace(String msg) {
- log.trace(msg);
- }
-
- public void trace(String msg, Throwable exception) {
- log.trace(msg, exception);
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLogFactory.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLogFactory.java 2008-10-31
10:28:46 UTC (rev 2701)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/Log4jLogFactory.java 2008-10-31
10:49:02 UTC (rev 2702)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.log;
-
-import org.apache.log4j.LogManager;
-
-
-/**
- * @author Tom Baeyens
- */
-public class Log4jLogFactory implements LogFactory {
-
- public Log getLog(String name) {
- return new Log4jLog(LogManager.getLogger(name));
- }
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFactory.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFactory.java 2008-10-31 10:28:46
UTC (rev 2701)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFactory.java 2008-10-31 10:49:02
UTC (rev 2702)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.log;
-
-
-/**
- * @author Tom Baeyens
- */
-public interface LogFactory {
-
- Log getLog(String name);
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFormatter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFormatter.java 2008-10-31
10:28:46 UTC (rev 2701)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/log/LogFormatter.java 2008-10-31
10:49:02 UTC (rev 2702)
@@ -1,81 +0,0 @@
-package org.jbpm.log;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Formatter;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-import org.jbpm.pvm.internal.util.ReflectUtil;
-
-public class LogFormatter extends Formatter {
-
- static final String NEWLINE = System.getProperty("line.separator");
- static final DateFormat dateTimeFormat = new
SimpleDateFormat("HH:mm:ss,SSS");
- static final Map<Level, String> levels = new HashMap<Level, String>();
- private static Map<Integer, Integer> indentations = new HashMap<Integer,
Integer>();
-
-
- static {
- levels.put(Level.ALL, "ALL");
- levels.put(Level.CONFIG, "CFG");
- levels.put(Level.FINE, "FIN");
- levels.put(Level.FINER, "FNR");
- levels.put(Level.FINEST, "FST");
- levels.put(Level.INFO, "INF");
- levels.put(Level.OFF, "OFF");
- levels.put(Level.SEVERE, "SEV");
- levels.put(Level.WARNING, "WRN");
- }
-
- public String format(LogRecord logRecord) {
- StringWriter msg = new StringWriter();
- if (logRecord.getThrown()!=null) {
- msg.append("### EXCEPTION ###########################################");
- msg.append(NEWLINE);
- }
- msg.append(dateTimeFormat.format(new Date()));
- msg.append(" ");
- msg.append(levels.get(logRecord.getLevel()));
- msg.append(" ");
-
- int threadId = logRecord.getThreadID();
- for (int i=0; i<getIndentation(threadId); i++) {
- msg.append(" ");
- }
-
- msg.append("| [");
-
- String loggerName = logRecord.getLoggerName();
- msg.append(ReflectUtil.getUnqualifiedClassName(loggerName));
-
- msg.append("] ");
-
- msg.append(logRecord.getMessage());
- if (logRecord.getThrown()!=null) {
- msg.append(NEWLINE);
- logRecord.getThrown().printStackTrace(new PrintWriter(msg));
- msg.append("### EXCEPTION ###########################################");
- }
- msg.append(NEWLINE);
- return msg.toString();
- }
-
- private int getIndentation(int threadId) {
- Integer indentation = indentations.get(threadId);
- if (indentation==null) {
- indentation = indentations.size();
- indentations.put(threadId, indentation);
- }
- return indentation;
- }
-
- public static void resetIndentation() {
- indentations = new HashMap<Integer, Integer>();
- }
-}
Modified: jbpm4/trunk/modules/test/pom.xml
===================================================================
--- jbpm4/trunk/modules/test/pom.xml 2008-10-31 10:28:46 UTC (rev 2701)
+++ jbpm4/trunk/modules/test/pom.xml 2008-10-31 10:49:02 UTC (rev 2702)
@@ -33,6 +33,11 @@
<version>${version}</version>
</dependency>
<dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-log</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>