[pal-cvs 3258] [992] added a logging mechanism.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 6月 20日 (金) 07:24:31 JST


Revision: 992
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=992
Author:   shinsuke
Date:     2008-06-20 07:24:31 +0900 (Fri, 20 Jun 2008)

Log Message:
-----------
added a logging mechanism.

Added Paths:
-----------
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/Log.java
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/LogFactory.java
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/resources/
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/resources/Messages.properties


-------------- next part --------------
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/Log.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/Log.java	                        (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/Log.java	2008-06-19 22:24:31 UTC (rev 992)
@@ -0,0 +1,220 @@
+package jp.sf.pal.portal.logging;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+public class Log implements org.apache.commons.logging.Log, Serializable
+{
+
+    private static final long serialVersionUID = -3677150409771058584L;
+
+    private org.apache.commons.logging.Log log;
+
+    private ResourceBundle resourceBundle;
+
+    public Log(org.apache.commons.logging.Log log, ResourceBundle resourceBundle)
+    {
+        this.log = log;
+        this.resourceBundle = resourceBundle;
+    }
+
+    public String getString(String messageCode)
+    {
+        return getString(messageCode, null);
+    }
+
+    public String getString(String messageCode, Object[] args)
+    {
+        String message = null;
+        try
+        {
+            message = resourceBundle.getString(messageCode);
+        }
+        catch (Exception e)
+        {
+            log.error(messageCode, e);
+            return messageCode;
+        }
+        // remove log level
+        message = message.substring(1);
+        if (args != null)
+        {
+            message = MessageFormat.format(message, args);
+        }
+        return message;
+    }
+
+    public void log(Throwable throwable)
+    {
+        error(throwable.getMessage(), throwable);
+    }
+
+    public void log(String messageCode)
+    {
+        log(messageCode, null, null);
+    }
+
+    public void log(String messageCode, Object[] args)
+    {
+        log(messageCode, args, null);
+    }
+
+    public void log(String messageCode, Throwable throwable)
+    {
+        log(messageCode, null, throwable);
+    }
+
+    public void log(String messageCode, Object[] args, Throwable throwable)
+    {
+        String message = null;
+        try
+        {
+            message = resourceBundle.getString(messageCode);
+        }
+        catch (Exception e)
+        {
+            log.error(messageCode, e);
+            return;
+        }
+        char messageType = message.charAt(0);
+        if (isEnabledFor(messageType))
+        {
+            // remove log level
+            message = message.substring(1);
+            if (args != null)
+            {
+                message = MessageFormat.format(message, args);
+            }
+            switch (messageType)
+            {
+            case 'D':
+                log.debug(message, throwable);
+                break;
+            case 'I':
+                log.info(message, throwable);
+                break;
+            case 'W':
+                log.warn(message, throwable);
+                break;
+            case 'E':
+                log.error(message, throwable);
+                break;
+            case 'F':
+                log.fatal(message, throwable);
+                break;
+            default:
+                throw new IllegalArgumentException(String.valueOf(messageType));
+            }
+        }
+    }
+
+    private boolean isEnabledFor(final char messageType)
+    {
+        switch (messageType)
+        {
+        case 'D':
+            return log.isDebugEnabled();
+        case 'I':
+            return log.isInfoEnabled();
+        case 'W':
+            return log.isWarnEnabled();
+        case 'E':
+            return log.isErrorEnabled();
+        case 'F':
+            return log.isFatalEnabled();
+        default:
+            throw new IllegalArgumentException(String.valueOf(messageType));
+        }
+    }
+
+    public void debug(Object arg0, Throwable arg1)
+    {
+        log.debug(arg0, arg1);
+    }
+
+    public void debug(Object arg0)
+    {
+        log.debug(arg0);
+    }
+
+    public void error(Object arg0, Throwable arg1)
+    {
+        log.error(arg0, arg1);
+    }
+
+    public void error(Object arg0)
+    {
+        log.error(arg0);
+    }
+
+    public void fatal(Object arg0, Throwable arg1)
+    {
+        log.fatal(arg0, arg1);
+    }
+
+    public void fatal(Object arg0)
+    {
+        log.fatal(arg0);
+    }
+
+    public void info(Object arg0, Throwable arg1)
+    {
+        log.info(arg0, arg1);
+    }
+
+    public void info(Object arg0)
+    {
+        log.info(arg0);
+    }
+
+    public boolean isDebugEnabled()
+    {
+        return log.isDebugEnabled();
+    }
+
+    public boolean isErrorEnabled()
+    {
+        return log.isErrorEnabled();
+    }
+
+    public boolean isFatalEnabled()
+    {
+        return log.isFatalEnabled();
+    }
+
+    public boolean isInfoEnabled()
+    {
+        return log.isInfoEnabled();
+    }
+
+    public boolean isTraceEnabled()
+    {
+        return log.isTraceEnabled();
+    }
+
+    public boolean isWarnEnabled()
+    {
+        return log.isWarnEnabled();
+    }
+
+    public void trace(Object arg0, Throwable arg1)
+    {
+        log.trace(arg0, arg1);
+    }
+
+    public void trace(Object arg0)
+    {
+        log.trace(arg0);
+    }
+
+    public void warn(Object arg0, Throwable arg1)
+    {
+        log.warn(arg0, arg1);
+    }
+
+    public void warn(Object arg0)
+    {
+        log.warn(arg0);
+    }
+}


Property changes on: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/Log.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/LogFactory.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/LogFactory.java	                        (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/LogFactory.java	2008-06-19 22:24:31 UTC (rev 992)
@@ -0,0 +1,46 @@
+package jp.sf.pal.portal.logging;
+
+import java.util.ResourceBundle;
+
+import org.apache.commons.logging.LogConfigurationException;
+
+public class LogFactory
+{
+
+    protected static ResourceBundle resourceBundle = ResourceBundle
+            .getBundle("jp.sf.pal.portal.logging.resources.Messages");
+
+    public static org.apache.commons.logging.LogFactory getFactory()
+            throws LogConfigurationException
+    {
+        return org.apache.commons.logging.LogFactory.getFactory();
+    }
+
+    public static Log getLog(Class clazz)
+    {
+        return new Log(org.apache.commons.logging.LogFactory.getLog(clazz),
+                resourceBundle);
+    }
+
+    public static Log getLog(String name)
+    {
+        return new Log(org.apache.commons.logging.LogFactory.getLog(name),
+                resourceBundle);
+    }
+
+    public static void release(ClassLoader classLoader)
+    {
+        org.apache.commons.logging.LogFactory.release(classLoader);
+    }
+
+    public static void releaseAll()
+    {
+        org.apache.commons.logging.LogFactory.releaseAll();
+    }
+
+    public static String objectId(Object o)
+    {
+        return org.apache.commons.logging.LogFactory.objectId(o);
+    }
+
+}


Property changes on: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/LogFactory.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/resources/Messages.properties
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/resources/Messages.properties	                        (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/resources/Messages.properties	2008-06-19 22:24:31 UTC (rev 992)
@@ -0,0 +1,80 @@
+# The format is XXYYYYY. XX(2 degits) is the number of a component. 
+# YYYYY(5 degits) is the number of a log message in the component.
+# 01: commons
+# 02: layout-portlets
+# 03: components/capability
+# 04: components/cm
+# 05: components/deploy-tool
+# 06: components/file-cache
+# 07: components/header-resource
+# 08: components/id-generator
+# 09: components/jetspeed
+0900001=I[0900001] Starting Jetspeed Engine ({0}) at {1}
+0900002=E[0900002] Jetspeed Initialization exception
+0900003=I[0900003] Finished starting Jetspeed Engine ({0}) at {1}.  Elapsed time: {2} seconds.
+0900004=W[0900004] No ContainerService defined for {0}
+0900005=I[0900005] Double initialization of Jetspeed was attempted!
+0900006=F[0900006] Jetspeed: init() failed.
+0900007=I[0900007] Jetspeed Initialization complete, Ready to service requests.
+0900008=F[0900008] Fatal error encountered while processing portal request.
+0900009=F[0900009] Jetspeed: shutdown() failed. 
+0900010=I[0900010] Done shutting down.
+0900011=I[0900011] Jetspeed Starting Initialization...
+0900012=I[0900012] Double initialization of Jetspeed was attempted.
+0900013=I[0900013] JetspeedServlet identifying web application root...
+0900014=I[0900014] JetspeedServlet identifed web application root as {0}
+0900015=I[0900015] JetspeedServlet attempting to create the  portlet engine...
+0900016=I[0900016] JetspeedServlet attempting to start the Jetspeed Portal Engine...
+0900017=I[0900017] JetspeedServlet has successfuly started the Jetspeed Portal Engine...
+0900018=F[0900018] Jetspeed: init() failed.
+0900019=I[0900019] Jetspeed Initialization complete, Ready to service requests.
+0900020=D[0900020] usernameKey={0}, passwordKey={1}, skipPasswordCheck={2}
+0900021=D[0900021] Authentication failure: username={0}
+0900022=D[0900022] path={0}, domain={1}, maxAge={2}, secure={3}, transferredInfo={4}
+0900023=W[0900023] Could not get the user info: {0}
+0900024=E[0900024] Could not create UserManager.
+0900025=E[0900025] Could not create RoleManager.
+0900026=E[0900026] Could not create GroupManager.
+0900027=E[0900027] Could not create Profiler.
+0900028=E[0900028] Could not create a user.
+0900029=E[0900029] Could not create a user.
+0900030=E[0900030] Could not remove a user.
+0900031=E[0900031] Could not update a user.
+0900032=E[0900032] Could not remove a user.
+0900033=E[0900033] Registration Error: Failed to rollback user {0}.
+0900034=E[0900034] Registration Error: Failed to create user folders for {0}, {1}.
+0900035=E[0900035] Registration Error: Failed to create registered user {0}.
+0900036=E[0900036] Sorry, but we were unable access the requested portlet.  Check the following exception.
+0900037=I[0900037] Aggregating {0}. Parallel: {1}, Sequential: {2}
+0900038=D[0900038] Rendering portlet fragment: [[name, {0}], [id, {1}]]
+0900039=E[0900039] Worker exception
+0900040=E[0900040] Exception during synchronizing all portlet rendering jobs.
+0900041=E[0900041] Exception during synchronizing all portlet rendering jobs.
+0900042=D[0900042] [CommonjWorkMonitorImpl] workAccepted: {0}
+0900043=D[0900043] [CommonjWorkMonitorImpl] workRejected: {0}
+0900044=D[0900044] [CommonjWorkMonitorImpl] workStarted: {0}
+0900045=D[0900045] [CommonjWorkMonitorImpl] workCompleted: {0}
+0900046=E[0900046] Exceptiong during job timeout monitoring.
+0900047=E[0900047] Exception during job monitoring.
+0900048=I[0900048] Portlet Rendering job to be interrupted by timeout ({0}ms): {1}
+0900049=E[0900049] Exceptiong during job killing.
+
+# 10: components/locator
+# 11: components/page-manager
+# 12: components/portal
+# 13: components/portal-site
+# 14: components/portlet-factory
+# 15: components/prefs
+# 16: components/profiler
+# 17: components/rdbms
+# 18: components/registry
+# 19: components/rewriter
+# 20: components/search
+# 21: components/security
+# 22: components/security-schema
+# 23: components/serializer
+# 24: components/sso
+# 25: components/statistics
+# 26: components/web-content
+# 27: components/webapp-logging
+


Property changes on: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/jp/sf/pal/portal/logging/resources/Messages.properties
___________________________________________________________________
Name: svn:eol-style
   + native


pal-cvs メーリングリストの案内
Back to archive index