You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2022/03/31 16:30:31 UTC

[GitHub] [daffodil] tuxji commented on a change in pull request #781: Daffodil 2643 tdml logs

tuxji commented on a change in pull request #781:
URL: https://github.com/apache/daffodil/pull/781#discussion_r839787859



##########
File path: build.sbt
##########
@@ -104,6 +104,7 @@ lazy val sapi             = Project("daffodil-sapi", file("daffodil-sapi")).conf
 lazy val tdmlLib             = Project("daffodil-tdml-lib", file("daffodil-tdml-lib")).configs(IntegrationTest)
                               .dependsOn(macroLib % "compile-internal", lib, io, io % "test->test")
                               .settings(commonSettings)
+                              .settings(libraryDependencies ++= Dependencies.core)

Review comment:
       Why is this change even needed?  You have `.settings(commonSettings)` on the previous line and that calls libraryDependencies ++= Dependencies.common, in short, core ++ infoset ++ test.  

##########
File path: daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLAppender.scala
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.daffodil.tdml
+
+import org.apache.logging.log4j.core.appender.AbstractAppender
+import org.apache.logging.log4j.core.filter.ThresholdFilter
+import org.apache.logging.log4j.core.LogEvent
+import org.apache.logging.log4j.core.Filter.Result
+import org.apache.logging.log4j.Level
+import org.apache.daffodil.api.Diagnostic
+import org.apache.daffodil.util.Maybe
+import org.apache.daffodil.util.Maybe._
+import org.apache.logging.log4j.core.config.plugins.{Plugin, PluginFactory}
+
+@Plugin(

Review comment:
       Please add comments here and below explaining what each class and object is used for.

##########
File path: daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLAppender.scala
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.daffodil.tdml
+
+import org.apache.logging.log4j.core.appender.AbstractAppender
+import org.apache.logging.log4j.core.filter.ThresholdFilter
+import org.apache.logging.log4j.core.LogEvent
+import org.apache.logging.log4j.core.Filter.Result
+import org.apache.logging.log4j.Level
+import org.apache.daffodil.api.Diagnostic
+import org.apache.daffodil.util.Maybe
+import org.apache.daffodil.util.Maybe._
+import org.apache.logging.log4j.core.config.plugins.{Plugin, PluginFactory}
+
+@Plugin(
+    name="CustomAppender",
+    category="Core",
+    elementType="appender"
+)
+class TDMLAppender 
+ extends AbstractAppender ("org.apache.daffodil.tdml", ThresholdFilter.createFilter(Level.INFO, Result.ACCEPT, Result.DENY), null, false, null) {
+
+    import TDMLAppender._
+
+    override def append(event: LogEvent): Unit = {
+        diagnostics = new LogDiagnostic(event.getMessage.getFormattedMessage) +: diagnostics
+    }
+}
+
+object TDMLAppender{
+    var diagnostics: Seq[Diagnostic] = Nil
+    var diagnostics2: Seq[String] = Nil
+
+    @PluginFactory
+    def createAppender(): TDMLAppender = {
+            new TDMLAppender
+    }
+
+    def getDiagnostics(): Seq[Throwable] = {
+        diagnostics
+    }
+
+    def clearDiagnostics(): Unit = {
+        diagnostics = Nil
+    }
+}
+
+class LogDiagnostic(msg: String)

Review comment:
       I can't find where LogDiagnostic is used?

##########
File path: daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/RunnerFactory.scala
##########
@@ -91,6 +91,8 @@ object Runner {
    */
   def defaultShouldDoWarningComparisonOnCrossTests = false
 
+  def defaultShouldDoLogComparisonCrossTests = false

Review comment:
       Please add `On` for consistency, `defaultShouldDoLogComparisonOnCrossTests`.

##########
File path: daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
##########
@@ -76,7 +76,10 @@ import org.apache.daffodil.util.Misc.hex2Bits
 import org.apache.daffodil.util.SchemaUtils
 import org.apache.daffodil.xml.DaffodilXMLLoader
 import org.apache.daffodil.xml.XMLUtils
-
+import org.apache.logging.log4j.LogManager
+import org.apache.logging.log4j.core.{Logger => log4jLogger}

Review comment:
       We capitalize classes by convention, `Log4jLogger`.

##########
File path: project/Dependencies.scala
##########
@@ -32,6 +32,7 @@ object Dependencies {
     "com.typesafe" % "config" % "1.4.2",
     "org.apache.logging.log4j" %% "log4j-api-scala" % "12.0",
     "org.apache.logging.log4j" % "log4j-api" % "2.17.2",
+    "org.apache.logging.log4j" % "log4j-core" % "2.17.2",
     "org.apache.logging.log4j" % "log4j-core" % "2.17.2" % "it,test",

Review comment:
       I believe line 36 is extraneous now that you've added line 35.  If log4j-core is available in compile scope, it'll also be available in test and integration test scopes too.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org