svn commit: r1867344 - in /ofbiz/ofbiz-framework/trunk/framework/webtools: groovyScripts/log/ src/main/groovy/ src/main/groovy/org/ src/main/groovy/org/apache/ src/main/groovy/org/apache/ofbiz/ src/main/groovy/org/apache/ofbiz/webtools/ src/main/groovy...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1867344 - in /ofbiz/ofbiz-framework/trunk/framework/webtools: groovyScripts/log/ src/main/groovy/ src/main/groovy/org/ src/main/groovy/org/apache/ src/main/groovy/org/apache/ofbiz/ src/main/groovy/org/apache/ofbiz/webtools/ src/main/groovy...

jleroux@apache.org
Author: jleroux
Date: Sun Sep 22 14:18:23 2019
New Revision: 1867344

URL: http://svn.apache.org/viewvc?rev=1867344&view=rev
Log:
Improved: Move Groovy scripts from /groovyScripts/ to /src/main/groovy/
(OFBIZ-11205)

Moves FetchLogs.groovy as a 1st step

Added:
    ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/
    ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/
    ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/
    ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/
    ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/
    ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/log/
    ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy   (with props)
Removed:
    ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/log/FetchLogs.groovy
Modified:
    ofbiz/ofbiz-framework/trunk/framework/webtools/widget/LogScreens.xml

Added: ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy?rev=1867344&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy Sun Sep 22 14:18:23 2019
@@ -0,0 +1,73 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.ofbiz.webtools.log
+
+import org.apache.ofbiz.base.util.FileUtil
+import org.apache.ofbiz.base.util.UtilProperties
+
+String ofbizLogDir = UtilProperties.getPropertyValue("debug", "log4j.appender.css.dir", "runtime/logs/")
+if (!ofbizLogDir.startsWith("/")) {
+    ofbizLogDir = System.getProperty("ofbiz.home") + "/" + ofbizLogDir
+}
+if (!ofbizLogDir.endsWith("/")) {
+    ofbizLogDir = ofbizLogDir.concat("/")
+}
+
+File runTimeLogDir = FileUtil.getFile(ofbizLogDir)
+File[] listLogFiles = runTimeLogDir.listFiles()
+String ofbizLogRegExp = UtilProperties.getPropertyValue("debug", "log4j.appender.css.fileNameRegExp", "[(ofbiz)|(error)].*")
+List listLogFileNames = []
+for (int i = 0; i < listLogFiles.length; i++) {
+    if (listLogFiles[i].isFile()) {
+        logFileName = listLogFiles[i].getName()
+        if (logFileName.matches(ofbizLogRegExp)) {
+            listLogFileNames.add(logFileName)
+        }
+    }
+}
+context.listLogFileNames = listLogFileNames.sort()
+
+if (parameters.logFileName && listLogFileNames.contains(parameters.logFileName)) {
+    List logLines = []
+    try {
+        File logFile = FileUtil.getFile(ofbizLogDir.concat(parameters.logFileName))
+        logFile.eachLine { line ->
+            if (parameters.searchString) {
+                if (!line.contains(parameters.searchString)) {
+                    return
+                }
+            }
+            type = ''
+            if (line.contains(" |I| ")) {
+                type = 'INFO'
+            } else if (line.contains(" |W| ")) {
+                type = 'WARN'
+            } else if (line.contains(" |E| ")) {
+                type = 'ERROR'
+            } else if (line.contains(" |D| ")) {
+                type = 'DEBUG'
+            }
+            logLines.add([type: type, line:line])
+        }
+    } catch (Exception e) {
+        Debug.logError(e, "FetchLogs.groovy");
+    }
+    context.logLines = logLines
+}

Propchange: ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/ofbiz-framework/trunk/framework/webtools/widget/LogScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/widget/LogScreens.xml?rev=1867344&r1=1867343&r2=1867344&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webtools/widget/LogScreens.xml (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webtools/widget/LogScreens.xml Sun Sep 22 14:18:23 2019
@@ -99,7 +99,7 @@ under the License.
                  <set field="titleProperty" value="PageTitleLogView"/>
                  <set field="tabButtonItem" value="logView"/>
                  <property-to-field field="parameters.logFileName" resource="debug" property="log4j.appender.css.defaultFile" default="ofbiz.log" no-locale="true"/>
-                 <script location="component://webtools/groovyScripts/log/FetchLogs.groovy"/>
+                 <script location="component://webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy"/>
              </actions>
              <widgets>
                  <decorator-screen name="log-decorator">
@@ -130,7 +130,7 @@ under the License.
              <actions>
                  <set field="titleProperty" value="PageTitleFetchLogs"/>
                  <set field="tabButtonItem" value="fetchLogs"/>
-                 <script location="component://webtools/groovyScripts/log/FetchLogs.groovy"/>
+                 <script location="component://webtools/src/main/groovy/org/apache/ofbiz/webtools/log/FetchLogs.groovy"/>
              </actions>
              <widgets>
                  <decorator-screen name="log-decorator">