From: <bd...@us...> - 2012-10-30 16:01:18
|
Revision: 14842 http://unicore.svn.sourceforge.net/unicore/?rev=14842&view=rev Author: bdemuth Date: 2012-10-30 16:01:08 +0000 (Tue, 30 Oct 2012) Log Message: ----------- tiny refactoring Modified Paths: -------------- unicore-portal/trunk/ui/src/main/java/eu/unicore/portal/ui/PortalApplication.java Added Paths: ----------- unicore-portal/trunk/core/src/main/java/eu/unicore/portal/core/logging/EventQueueAppender.java Removed Paths: ------------- unicore-portal/trunk/ui/src/main/java/eu/unicore/portal/ui/logging/VaadinNotificationAppender.java Added: unicore-portal/trunk/core/src/main/java/eu/unicore/portal/core/logging/EventQueueAppender.java =================================================================== --- unicore-portal/trunk/core/src/main/java/eu/unicore/portal/core/logging/EventQueueAppender.java (rev 0) +++ unicore-portal/trunk/core/src/main/java/eu/unicore/portal/core/logging/EventQueueAppender.java 2012-10-30 16:01:08 UTC (rev 14842) @@ -0,0 +1,72 @@ +package eu.unicore.portal.core.logging; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.spi.LocationInfo; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.spi.ThrowableInformation; + +import eu.unicore.portal.core.Session; +import eu.unicore.portal.core.logging.Event; +import eu.unicore.problemutil.Problem; +import eu.unicore.problemutil.config.ProblemConfig; + +public class EventQueueAppender extends AppenderSkeleton{ + + private ProblemConfig problemConfig = createProblemConfig(); + + public void close() { + + } + + public boolean requiresLayout() { + return false; + } + + @Override + protected void append(LoggingEvent event) { + + Throwable t = null; + String details = ""; + ThrowableInformation ti = event.getThrowableInformation(); + if(ti != null) + { + t = ti.getThrowable(); + if (t != null) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(os); + t.printStackTrace(ps); + details = os.toString(); + } + } + Date d = new Date(event.getTimeStamp()); + Problem[] problems = null; + if(t != null) + { + List<Problem> matched = problemConfig + .matchProblems(event.getMessage().toString(), t); + problems = matched.toArray(new Problem[matched.size()]); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + String id = event.getLevel()+": "+sdf.format(d); + LocationInfo loc = event.getLocationInformation(); + id+=", class: "+loc.getClassName()+", line:"+loc.getLineNumber(); + int lvl = event.getLevel().toInt(); + + Event myEvent = new Event(id,lvl,event.getRenderedMessage(),d,problems,t,details); + Session.getCurrent().getEventQueue().addEvent(myEvent); + } + + + private ProblemConfig createProblemConfig() + { + ProblemConfig result = new ProblemConfig(); + return result; + } + +} Modified: unicore-portal/trunk/ui/src/main/java/eu/unicore/portal/ui/PortalApplication.java =================================================================== --- unicore-portal/trunk/ui/src/main/java/eu/unicore/portal/ui/PortalApplication.java 2012-10-30 15:57:42 UTC (rev 14841) +++ unicore-portal/trunk/ui/src/main/java/eu/unicore/portal/ui/PortalApplication.java 2012-10-30 16:01:08 UTC (rev 14842) @@ -17,9 +17,9 @@ import eu.unicore.hila.grid.unicore6.Unicore6Grid; import eu.unicore.portal.core.RequestLifecycleManager; import eu.unicore.portal.core.Session; +import eu.unicore.portal.core.logging.EventQueueAppender; import eu.unicore.portal.ui.i18n.PortalMessages; import eu.unicore.portal.ui.logging.VaadinEventQueueListener; -import eu.unicore.portal.ui.logging.VaadinNotificationAppender; import eu.unicore.portal.ui.menus.MenuManager; import eu.unicore.portal.ui.views.LoginView; import eu.unicore.portal.ui.views.ViewManager; @@ -56,7 +56,7 @@ synchronized (appenderSync) { if(logAppender == null) { - logAppender = new VaadinNotificationAppender(); + logAppender = new EventQueueAppender(); Logger root = LogManager.getRootLogger(); root.addAppender(logAppender); Deleted: unicore-portal/trunk/ui/src/main/java/eu/unicore/portal/ui/logging/VaadinNotificationAppender.java =================================================================== --- unicore-portal/trunk/ui/src/main/java/eu/unicore/portal/ui/logging/VaadinNotificationAppender.java 2012-10-30 15:57:42 UTC (rev 14841) +++ unicore-portal/trunk/ui/src/main/java/eu/unicore/portal/ui/logging/VaadinNotificationAppender.java 2012-10-30 16:01:08 UTC (rev 14842) @@ -1,72 +0,0 @@ -package eu.unicore.portal.ui.logging; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.LocationInfo; -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.spi.ThrowableInformation; - -import eu.unicore.portal.core.Session; -import eu.unicore.portal.core.logging.Event; -import eu.unicore.problemutil.Problem; -import eu.unicore.problemutil.config.ProblemConfig; - -public class VaadinNotificationAppender extends AppenderSkeleton{ - - private ProblemConfig problemConfig = createProblemConfig(); - - public void close() { - - } - - public boolean requiresLayout() { - return false; - } - - @Override - protected void append(LoggingEvent event) { - - Throwable t = null; - String details = ""; - ThrowableInformation ti = event.getThrowableInformation(); - if(ti != null) - { - t = ti.getThrowable(); - if (t != null) { - ByteArrayOutputStream os = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(os); - t.printStackTrace(ps); - details = os.toString(); - } - } - Date d = new Date(event.getTimeStamp()); - Problem[] problems = null; - if(t != null) - { - List<Problem> matched = problemConfig - .matchProblems(event.getMessage().toString(), t); - problems = matched.toArray(new Problem[matched.size()]); - } - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - String id = event.getLevel()+": "+sdf.format(d); - LocationInfo loc = event.getLocationInformation(); - id+=", class: "+loc.getClassName()+", line:"+loc.getLineNumber(); - int lvl = event.getLevel().toInt(); - - Event myEvent = new Event(id,lvl,event.getRenderedMessage(),d,problems,t,details); - Session.getCurrent().getEventQueue().addEvent(myEvent); - } - - - private ProblemConfig createProblemConfig() - { - ProblemConfig result = new ProblemConfig(); - return result; - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |