You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2018/04/02 20:32:10 UTC
logging-log4j-scala git commit: Move sample module into sbt project
Repository: logging-log4j-scala
Updated Branches:
refs/heads/sbt 59f47b878 -> 94faa7984
Move sample module into sbt project
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/commit/94faa798
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/tree/94faa798
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/diff/94faa798
Branch: refs/heads/sbt
Commit: 94faa7984a5df8d4e6ab1c8dba37c420bbe6d361
Parents: 59f47b8
Author: Matt Sicker <bo...@gmail.com>
Authored: Mon Apr 2 15:31:59 2018 -0500
Committer: Matt Sicker <bo...@gmail.com>
Committed: Mon Apr 2 15:31:59 2018 -0500
----------------------------------------------------------------------
build.sbt | 33 ++++----
log4j-api-scala-sample/pom.xml | 82 --------------------
.../src/main/resources/log4j2.xml | 32 --------
.../logging/log4j/scala/sample/LoggingApp.scala | 54 -------------
.../src/site/markdown/index.md | 20 -----
log4j-api-scala-sample/src/site/site.xml | 30 -------
project/Dependencies.scala | 1 +
sample/src/main/resources/log4j2.xml | 32 ++++++++
.../logging/log4j/scala/sample/LoggingApp.scala | 54 +++++++++++++
9 files changed, 102 insertions(+), 236 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/94faa798/build.sbt
----------------------------------------------------------------------
diff --git a/build.sbt b/build.sbt
index 5bb6b15..9398b25 100644
--- a/build.sbt
+++ b/build.sbt
@@ -127,23 +127,20 @@ lazy val root = (project in file("."))
.enablePlugins(SbtOsgi)
.settings(bundleSettings: _*)
-//lazy val nopublish = Seq(
-// publish := {},
-// publishLocal := {},
-// publishM2 := {},
-// skip in publish := true
-//)
+lazy val nopublish = Seq(
+ publish := {},
+ publishLocal := {},
+ publishM2 := {},
+ skip in publish := true
+)
-//lazy val sample = (project in file("sample"))
-// .settings(metadataSettings: _*)
-// .settings(nopublish: _*)
-// .settings(
-// name := "log4j-api-scala-sample",
-// scalaVersion := scala212,
-// libraryDependencies := Seq(
-// "org.apache.logging.log4j" % "log4j-api" % log4j,
-// "org.apache.logging.log4j" % "log4j-core" % log4j % Runtime
-// )
-// )
-// .dependsOn(root)
+lazy val sample = (project in file("sample"))
+ .settings(metadataSettings: _*)
+ .settings(compileSettings: _*)
+ .settings(nopublish: _*)
+ .settings(
+ name := "log4j-api-scala-sample",
+ libraryDependencies := Seq(log4jApi, log4jCore)
+ )
+ .dependsOn(root)
http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/94faa798/log4j-api-scala-sample/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-api-scala-sample/pom.xml b/log4j-api-scala-sample/pom.xml
deleted file mode 100644
index 2f8b97b..0000000
--- a/log4j-api-scala-sample/pom.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-scala</artifactId>
- <version>12.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
- <artifactId>log4j-api-scala-sample</artifactId>
- <packaging>jar</packaging>
- <name>Scala API samples</name>
- <url>http://http://logging.apache.org/log4j/2.x/</url>
- <properties>
- <scala.version>2.12.4</scala.version>
- <scala.maven.plugin.version>3.3.1</scala.maven.plugin.version>
- <log4jParentDir>${basedir}/..</log4jParentDir>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api-scala_2.12</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- <build>
- <sourceDirectory>src/main/scala</sourceDirectory>
- <plugins>
- <plugin>
- <groupId>net.alchim31.maven</groupId>
- <artifactId>scala-maven-plugin</artifactId>
- <version>${scala.maven.plugin.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <args>
- <arg>-feature</arg>
- <arg>-unchecked</arg>
- <arg>-deprecation</arg>
- </args>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.5.0</version>
- <configuration>
- <mainClass>org.apache.logging.log4j.scala.sample.LoggingApp</mainClass>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/94faa798/log4j-api-scala-sample/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/log4j-api-scala-sample/src/main/resources/log4j2.xml b/log4j-api-scala-sample/src/main/resources/log4j2.xml
deleted file mode 100644
index 1c8703b..0000000
--- a/log4j-api-scala-sample/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
-
--->
-<Configuration name="ScalaApiSample" status="error">
- <Appenders>
- <Console name="Console">
- <PatternLayout>
- <Pattern>%d [%X{correlationId}] %5p %c{1} %X %F:%L - %m%n</Pattern>
- </PatternLayout>
- </Console>
- </Appenders>
- <Loggers>
- <Root level="TRACE">
- <AppenderRef ref="Console"/>
- </Root>
- </Loggers>
-</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/94faa798/log4j-api-scala-sample/src/main/scala/org/apache/logging/log4j/scala/sample/LoggingApp.scala
----------------------------------------------------------------------
diff --git a/log4j-api-scala-sample/src/main/scala/org/apache/logging/log4j/scala/sample/LoggingApp.scala b/log4j-api-scala-sample/src/main/scala/org/apache/logging/log4j/scala/sample/LoggingApp.scala
deleted file mode 100644
index c071673..0000000
--- a/log4j-api-scala-sample/src/main/scala/org/apache/logging/log4j/scala/sample/LoggingApp.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.logging.log4j.scala.sample
-
-import java.util.UUID
-
-import org.apache.logging.log4j.Level
-import org.apache.logging.log4j.message.MessageFactory2
-import org.apache.logging.log4j.scala.{Logging, LoggingContext}
-
-object LoggingApp extends App with Logging {
-
- val s1 = "foo"
- val s2 = "bar"
- val t = new RuntimeException("error")
-
- logger.info(s"Hello, world: $s1 $s2")
-
- logger.traceEntry()
- logger.traceEntry(s1, s2)
- val entryMessage = logger.traceEntry(logger.delegate.getMessageFactory.asInstanceOf[MessageFactory2].newMessage("foobar": CharSequence))
-
- logger.traceExit()
- logger.traceExit(s2)
- logger.traceExit(entryMessage)
- logger.traceExit(entryMessage, s2)
- logger.traceExit(logger.delegate.getMessageFactory.asInstanceOf[MessageFactory2].newMessage("bonsai": CharSequence), s2)
-
- logger.throwing(t)
- logger.throwing(Level.INFO, t)
-
- logger.catching(t)
- logger.catching(Level.INFO, t)
-
- LoggingContext("correlationId") = UUID.randomUUID().toString
- logger.info("Logging with a correlation ID set")
- LoggingContext.clear()
- logger.info("Logging without the correlation ID")
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/94faa798/log4j-api-scala-sample/src/site/markdown/index.md
----------------------------------------------------------------------
diff --git a/log4j-api-scala-sample/src/site/markdown/index.md b/log4j-api-scala-sample/src/site/markdown/index.md
deleted file mode 100644
index cd207b8..0000000
--- a/log4j-api-scala-sample/src/site/markdown/index.md
+++ /dev/null
@@ -1,20 +0,0 @@
-<!--
- 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.
--->
-# Log4j Scala API Sample
-
-This project demonstrates sample usage of Log4j Scala API. The source code is
-provided for Scala 2.12, but the API works the same in Scala 2.11 and 2.10.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/94faa798/log4j-api-scala-sample/src/site/site.xml
----------------------------------------------------------------------
diff --git a/log4j-api-scala-sample/src/site/site.xml b/log4j-api-scala-sample/src/site/site.xml
deleted file mode 100644
index f46fa51..0000000
--- a/log4j-api-scala-sample/src/site/site.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ 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.
- -->
-<project name="Log4j Scala API"
- xmlns="http://maven.apache.org/DECORATION/1.7.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.7.0 http://maven.apache.org/xsd/decoration-1.7.0.xsd">
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/"/>
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="../index.html"/>
- </links>
- <menu ref="reports"/>
- </body>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/94faa798/project/Dependencies.scala
----------------------------------------------------------------------
diff --git a/project/Dependencies.scala b/project/Dependencies.scala
index 93b3aff..7321de4 100644
--- a/project/Dependencies.scala
+++ b/project/Dependencies.scala
@@ -29,6 +29,7 @@ object Dependencies {
private val log4jV = "2.11.0"
val log4jApi = "org.apache.logging.log4j" % "log4j-api" % log4jV
val log4jApiTests = "org.apache.logging.log4j" % "log4j-api" % log4jV % Test classifier "tests"
+ val log4jCore = "org.apache.logging.log4j" % "log4j-core" % log4jV % Runtime
val junit = "junit" % "junit" % "4.12" % Test
val scalatest = "org.scalatest" %% "scalatest" % "3.0.4" % Test
val mockito = "org.mockito" % "mockito-core" % "1.10.19" % Test
http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/94faa798/sample/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/sample/src/main/resources/log4j2.xml b/sample/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..1c8703b
--- /dev/null
+++ b/sample/src/main/resources/log4j2.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+<Configuration name="ScalaApiSample" status="error">
+ <Appenders>
+ <Console name="Console">
+ <PatternLayout>
+ <Pattern>%d [%X{correlationId}] %5p %c{1} %X %F:%L - %m%n</Pattern>
+ </PatternLayout>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="TRACE">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/94faa798/sample/src/main/scala/org/apache/logging/log4j/scala/sample/LoggingApp.scala
----------------------------------------------------------------------
diff --git a/sample/src/main/scala/org/apache/logging/log4j/scala/sample/LoggingApp.scala b/sample/src/main/scala/org/apache/logging/log4j/scala/sample/LoggingApp.scala
new file mode 100644
index 0000000..c071673
--- /dev/null
+++ b/sample/src/main/scala/org/apache/logging/log4j/scala/sample/LoggingApp.scala
@@ -0,0 +1,54 @@
+/*
+ * 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.logging.log4j.scala.sample
+
+import java.util.UUID
+
+import org.apache.logging.log4j.Level
+import org.apache.logging.log4j.message.MessageFactory2
+import org.apache.logging.log4j.scala.{Logging, LoggingContext}
+
+object LoggingApp extends App with Logging {
+
+ val s1 = "foo"
+ val s2 = "bar"
+ val t = new RuntimeException("error")
+
+ logger.info(s"Hello, world: $s1 $s2")
+
+ logger.traceEntry()
+ logger.traceEntry(s1, s2)
+ val entryMessage = logger.traceEntry(logger.delegate.getMessageFactory.asInstanceOf[MessageFactory2].newMessage("foobar": CharSequence))
+
+ logger.traceExit()
+ logger.traceExit(s2)
+ logger.traceExit(entryMessage)
+ logger.traceExit(entryMessage, s2)
+ logger.traceExit(logger.delegate.getMessageFactory.asInstanceOf[MessageFactory2].newMessage("bonsai": CharSequence), s2)
+
+ logger.throwing(t)
+ logger.throwing(Level.INFO, t)
+
+ logger.catching(t)
+ logger.catching(Level.INFO, t)
+
+ LoggingContext("correlationId") = UUID.randomUUID().toString
+ logger.info("Logging with a correlation ID set")
+ LoggingContext.clear()
+ logger.info("Logging without the correlation ID")
+
+}
\ No newline at end of file