Author: jleroux
Date: Thu Oct 5 02:06:02 2006 New Revision: 453151 URL: http://svn.apache.org/viewvc?view=rev&rev=453151 Log: A patch from Peter Goron : Migrate webtools debug level screens to widget and add dynamic configuration of log4j loggers (https://issues.apache.org/jira/browse/OFBIZ-361) I did not have a lot of time to test this patch (after a quick review I only switched some interactiv debug levels). It seems well done and very interesting. Thanks Peter. Modified: incubator/ofbiz/trunk/framework/common/servicedef/services.xml incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml incubator/ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl Modified: incubator/ofbiz/trunk/framework/common/servicedef/services.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/servicedef/services.xml?view=diff&rev=453151&r1=453150&r2=453151 ============================================================================== --- incubator/ofbiz/trunk/framework/common/servicedef/services.xml (original) +++ incubator/ofbiz/trunk/framework/common/servicedef/services.xml Thu Oct 5 02:06:02 2006 @@ -48,16 +48,23 @@ <attribute name="noteId" type="String" mode="OUT"/> </service> - <service name="updateDebugLevel" engine="java" - location="org.ofbiz.common.CommonServices" invoke="setDebugLevels"> + <service name="adjustDebugingLevels" engine="java" + location="org.ofbiz.common.CommonServices" invoke="adjustDebugingLevels" auth="true"> <description>Sets/Updates cached debugging levels</description> - <attribute name="verbose" type="Boolean" mode="IN" optional="true"/> - <attribute name="timing" type="Boolean" mode="IN" optional="true"/> - <attribute name="info" type="Boolean" mode="IN" optional="true"/> - <attribute name="important" type="Boolean" mode="IN" optional="true"/> - <attribute name="warning" type="Boolean" mode="IN" optional="true"/> - <attribute name="error" type="Boolean" mode="IN" optional="true"/> - <attribute name="fatal" type="Boolean" mode="IN" optional="true"/> + <attribute name="fatal" type="String" mode="IN" optional="true"/> + <attribute name="error" type="String" mode="IN" optional="true"/> + <attribute name="warning" type="String" mode="IN" optional="true"/> + <attribute name="important" type="String" mode="IN" optional="true"/> + <attribute name="info" type="String" mode="IN" optional="true"/> + <attribute name="timing" type="String" mode="IN" optional="true"/> + <attribute name="verbose" type="String" mode="IN" optional="true"/> + </service> + <service name="addOrUpdateLogger" engine="java" + location="org.ofbiz.common.CommonServices" invoke="addOrUpdateLogger" auth="true"> + <description>Add/Update logger in logging system</description> + <attribute name="name" type="String" mode="IN" optional="false"/> + <attribute name="level" type="String" mode="IN" optional="false"/> + <attribute name="additivity" type="String" mode="IN" optional="true"/> </service> <service name="displayXaDebugInfo" engine="java" Modified: incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java?view=diff&rev=453151&r1=453150&r2=453151 ============================================================================== --- incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java (original) +++ incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java Thu Oct 5 02:06:02 2006 @@ -30,6 +30,8 @@ import javax.mail.internet.MimeMessage; import javax.transaction.xa.XAException; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; @@ -172,45 +174,33 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map setDebugLevels(DispatchContext dctx, Map context) { - Boolean verbose = (Boolean) context.get("verbose"); - Boolean timing = (Boolean) context.get("timing"); - Boolean info = (Boolean) context.get("info"); - Boolean important = (Boolean) context.get("important"); - Boolean warning = (Boolean) context.get("warning"); - Boolean error = (Boolean) context.get("error"); - Boolean fatal = (Boolean) context.get("fatal"); - - if (verbose != null) - Debug.set(Debug.VERBOSE, verbose.booleanValue()); - else - Debug.set(Debug.VERBOSE, false); - if (timing != null) - Debug.set(Debug.TIMING, timing.booleanValue()); - else - Debug.set(Debug.TIMING, false); - if (info != null) - Debug.set(Debug.INFO, info.booleanValue()); - else - Debug.set(Debug.INFO, false); - if (important != null) - Debug.set(Debug.IMPORTANT, important.booleanValue()); - else - Debug.set(Debug.IMPORTANT, false); - if (warning != null) - Debug.set(Debug.WARNING, warning.booleanValue()); - else - Debug.set(Debug.WARNING, false); - if (error != null) - Debug.set(Debug.ERROR, error.booleanValue()); - else - Debug.set(Debug.ERROR, false); - if (fatal != null) - Debug.set(Debug.FATAL, fatal.booleanValue()); - else - Debug.set(Debug.FATAL, false); - - return ServiceUtil.returnSuccess(); + public static Map adjustDebugingLevels(DispatchContext dctc, Map context) { + Debug.set(Debug.FATAL, "Y".equalsIgnoreCase((String) context.get("fatal"))); + Debug.set(Debug.ERROR, "Y".equalsIgnoreCase((String) context.get("error"))); + Debug.set(Debug.WARNING, "Y".equalsIgnoreCase((String) context.get("warning"))); + Debug.set(Debug.IMPORTANT, "Y".equalsIgnoreCase((String) context.get("important"))); + Debug.set(Debug.INFO, "Y".equalsIgnoreCase((String) context.get("info"))); + Debug.set(Debug.TIMING, "Y".equalsIgnoreCase((String) context.get("timing"))); + Debug.set(Debug.VERBOSE, "Y".equalsIgnoreCase((String) context.get("verbose"))); + + return ServiceUtil.returnSuccess(); + } + + public static Map addOrUpdateLogger(DispatchContext dctc, Map context) { + String name = (String) context.get("name"); + String level = (String) context.get("level"); + boolean additivity = "Y".equalsIgnoreCase((String) context.get("additivity")); + + Logger logger = null; + if ("root".equals(name)) { + logger = Logger.getRootLogger(); + } else { + logger = Logger.getLogger(name); + } + logger.setLevel(Level.toLevel(level)); + logger.setAdditivity(additivity); + + return ServiceUtil.returnSuccess(); } public static Map forceGc(DispatchContext dctx, Map context) { @@ -473,4 +463,5 @@ } } } + Modified: incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties?view=diff&rev=453151&r1=453150&r2=453151 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties (original) +++ incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties Thu Oct 5 02:06:02 2006 @@ -26,18 +26,33 @@ PageTitleEntityImportDir=XML Data Import Dir PageTitleEntitySyncStatus=Entity Sync Status PageTitleEntitySQLProcessor=Entity SQL Processor +PageTitleLogConfiguration=Debugging Levels WebtoolsAbsolutePath=Absolute directory path +WebtoolsAddLoggerFormDescription=This form allows you to enable a logger for a specific package or class. WebtoolsCreateDummyFks=Create "Dummy" FKs +WebtoolsDebuggingLevelFormDescription=This form allows you to change application debugging levels. WebtoolsDeleteFiles=Delete Files Afterwards? WebtoolsEntityDataMaintenance=Entity Data Maintenance +WebtoolsErrorLogLevel=Error +WebtoolsErrorLogLevelTooltip=The Error level designates error events that might still allow the application to continue running. WebtoolsExport=Export WebtoolsExportFromDataSource=XML Export from DataSource(s) +WebtoolsFatalLogLevel=Fatal +WebtoolsFatalLogLevelTooltip=The Fatal level designates very severe error events that will presumably lead the application to abort. WebtoolsImport=Import +WebtoolsImportantLogLevel=Important +WebtoolsImportantLogLevelTooltip=The Important level designates informational messages that highlight the progress of the application at coarse-grained level. WebtoolsImportFile=Import File WebtoolsImportText=Import Text WebtoolsImportToDataSource=XML Import to DataSource(s) +WebtoolsInfoLogLevel=Info +WebtoolsInfoLogLevelTooltip=The Info level designates informational messages that highlight the progress of the application at coarse-grained level. WebtoolsIsURL=Is URL? +WebtoolsLoggerAdditivity=Additivity +WebtoolsLoggerLevel=Level +WebtoolsLoggerListFormDescription=This form show all enabled loggers. +WebtoolsLoggerName=Name WebtoolsMainPage=WebTools Main Page WebtoolsMaintainTimestamps=Maintain Timestamps? WebtoolsMessage1=This page can be used to export data from the database @@ -52,3 +67,9 @@ WebtoolsPause=Pause (secs) between files WebtoolsResults=Results WebtoolsTimeoutSeconds=TX Timeout Seconds (for each entity) +WebtoolsTimingLogLevel=Timing +WebtoolsTimingLogLevelTooltip=The Timing Level designates fine-grained informational events that are most useful to debug an application. +WebtoolsVerboseLogLevel=Verbose +WebtoolsVerboseLogLevelTooltip=The Verbose Level designates fine-grained informational events that are most useful to debug an application. +WebtoolsWarningLogLevel=Warning +WebtoolsWarningLogLevelTooltip=The Warning level designates potentially harmful situations. Modified: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml?view=diff&rev=453151&r1=453150&r2=453151 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml (original) +++ incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml Thu Oct 5 02:06:02 2006 @@ -24,6 +24,7 @@ <handler name="java" type="request" class="org.ofbiz.webapp.event.JavaEventHandler"/> <handler name="soap" type="request" class="org.ofbiz.webapp.event.SOAPEventHandler"/> <handler name="service" type="request" class="org.ofbiz.webapp.event.ServiceEventHandler"/> + <handler name="service-multi" type="request" class="org.ofbiz.webapp.event.ServiceMultiEventHandler"/> <handler name="simple" type="request" class="org.ofbiz.webapp.event.SimpleEventHandler"/> <handler name="jpublish" type="view" class="org.ofbiz.webapp.view.JPublishViewHandler"/> @@ -290,15 +291,24 @@ <response name="success" type="view" value="StatBinsHistory"/> </request-map> - <request-map uri="debuglevels"> - <security https="true" auth="true"/> - <response name="success" type="view" value="debuglevels"/> + <request-map uri="LogConfiguration"> + <security https="true" auth="true"/> + <response name="success" type="view" value="LogConfiguration"/> + </request-map> + <request-map uri="AddLogger"> + <security https="true" auth="true"/> + <event type="service" invoke="addOrUpdateLogger"/> + <response name="success" type="view" value="LogConfiguration"/> + </request-map> + <request-map uri="UpdateLogger"> + <security https="true" auth="true"/> + <event type="service-multi" invoke="addOrUpdateLogger"/> + <response name="success" type="view" value="LogConfiguration"/> </request-map> - <request-map uri="updateDebugLevel"> + <request-map uri="AdjustDebugingLevels"> <security https="true" auth="true"/> - <event type="service" invoke="updateDebugLevel"/> - <response name="success" type="view" value="debuglevels"/> - <response name="error" type="view" value="debuglevels"/> + <event type="service" invoke="adjustDebugingLevels"/> + <response name="success" type="view" value="LogConfiguration"/> </request-map> <request-map uri="serviceList"> @@ -518,7 +528,7 @@ <view-map name="logikus" type="region"/> <view-map name="readxpdl" type="region"/> <view-map name="workflowMonitor" type="region"/> - <view-map name="debuglevels" type="region"/> + <view-map name="LogConfiguration" type="screen" page="component://webtools/widget/LogScreens.xml#LogConfiguration"/> <view-map name="StatsSinceStart" type="region"/> <view-map name="StatBinsHistory" type="region"/> Modified: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml?view=diff&rev=453151&r1=453150&r2=453151 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml (original) +++ incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml Thu Oct 5 02:06:02 2006 @@ -123,11 +123,6 @@ <put section="content" content="/period/EditCustomTimePeriod.jsp"/> </define> - <define id="debuglevels" region="MAIN_REGION"> - <put section="title">Debugging Levels</put> - <put section="content" content="/debug.jsp"/> - </define> - <define id="threadList" region="MAIN_REGION"> <put section="title">Thread List</put> <put section="content" content="/service/threads.jsp"/> Modified: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl?view=diff&rev=453151&r1=453150&r2=453151 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl (original) +++ incubator/ofbiz/trunk/framework/webtools/webapp/webtools/main.ftl Thu Oct 5 02:06:02 2006 @@ -48,7 +48,7 @@ <li><div class="tabletext">Cache & Debug Tools</div> <ul> <li><a href="<@ofbizUrl>/FindUtilCache</@ofbizUrl>" class="linktext">Cache Maintenance</a> - <li><a href="<@ofbizUrl>/debuglevels</@ofbizUrl>" class="linktext">Adjust Debugging Levels</a> + <li><a href="<@ofbizUrl>/LogConfiguration</@ofbizUrl>" class="linktext">Adjust Debugging Levels</a> </ul> <#if security.hasPermission("ENTITY_MAINT", session)> <li><div class="tabletext">Entity Engine Tools</div> |
Free forum by Nabble | Edit this page |