Come to think of it, this can be more easily accomplished via an SBT build script. Cross compiling a library against multiple versions of Scala is much easier there.
On 11 November 2017 at 18:16, Matt Sicker <boa...@gmail.com> wrote: > The module name reflects the version of Scala (or Scala.js, Scala Native, > SBT, etc.) it was compiled for. With at least Scala 2.10 and beyond, > version-specific artifacts can be done for major versions. With a milestone > release, I don't think there is guaranteed binary compatibility with the > actual release. > > Perhaps just publishing it as a snapshot only would work? That way, users > testing out Scala 2.13 can just pull in the snapshot. > > On 11 November 2017 at 17:49, Gary Gregory <garydgreg...@gmail.com> wrote: > >> On Sat, Nov 11, 2017 at 3:51 PM, Matt Sicker <boa...@gmail.com> wrote: >> >> > I've seen on Maven Central before that a few Scala libraries have >> published >> > artifacts for 2.13.0 milestones. See for example: < >> > https://search.maven.org/#artifactdetails%7Corg. >> > scalatest%7Cscalatest_2.13.0-M2%7C3.0.4%7Cbundle>. >> > It seems like if we published the module by naming it >> > "log4j-api-scala_2.13.0-M2", we could have a version specific to that >> > milestone at least. >> > >> >> Hi Matt, >> >> The scalatest module has the milestone number in the name but not >> scala-library for example. >> >> Why bother with changing the module name. If it came out today, our >> version >> 12.0 of log4j-api-scala_2.13 would be at the 2.13.0-M2 level. Then our >> 13.0 >> can be at the next M level and so on. >> >> What am I missing? >> >> Gary >> >> >> > On 11 November 2017 at 16:26, <ggreg...@apache.org> wrote: >> > >> > > Repository: logging-log4j-scala >> > > Updated Branches: >> > > refs/heads/master 5a71e5caa -> 184045cbc >> > > >> > > >> > > Add placeholder for Scala 2.13 but do not enable the module. >> > > >> > > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/r >> epo >> > > Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > commit/184045cb >> > > Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > tree/184045cb >> > > Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > diff/184045cb >> > > >> > > Branch: refs/heads/master >> > > Commit: 184045cbc7a517faef2a709aa68e83d7a0053599 >> > > Parents: 5a71e5c >> > > Author: Gary Gregory <ggreg...@apache.org> >> > > Authored: Sat Nov 11 15:26:01 2017 -0700 >> > > Committer: Gary Gregory <ggreg...@apache.org> >> > > Committed: Sat Nov 11 15:26:01 2017 -0700 >> > > >> > > ------------------------------------------------------------ >> ---------- >> > > log4j-api-scala_2.13/pom.xml | 145 +++++ >> > > .../org/apache/logging/log4j/scala/Logger.scala | 592 >> > +++++++++++++++++++ >> > > .../logging/log4j/scala/LoggerMacro.scala | 425 +++++++++++++ >> > > .../apache/logging/log4j/scala/Logging.scala | 30 + >> > > .../logging/log4j/scala/LoggingContext.scala | 84 +++ >> > > log4j-api-scala_2.13/src/site/markdown/index.md | 74 +++ >> > > log4j-api-scala_2.13/src/site/site.xml | 30 + >> > > .../apache/logging/log4j/scala/LoggerTest.scala | 552 >> +++++++++++++++++ >> > > .../log4j/scala/LoggingContextTest.scala | 115 ++++ >> > > pom.xml | 1 + >> > > 10 files changed, 2048 insertions(+) >> > > ------------------------------------------------------------ >> ---------- >> > > >> > > >> > > http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > blob/184045cb/log4j-api-scala_2.13/pom.xml >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/log4j-api-scala_2.13/pom.xml >> b/log4j-api-scala_2.13/pom.xml >> > > new file mode 100644 >> > > index 0000000..ea0f19c >> > > --- /dev/null >> > > +++ b/log4j-api-scala_2.13/pom.xml >> > > @@ -0,0 +1,145 @@ >> > > +<?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 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/ma >> ven-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_2.13</artifactId> >> > > + <packaging>jar</packaging> >> > > + <name>Scala 2.13 wrapper for Log4j API</name> >> > > + <description>Scala wrapper for Log4j API</description> >> > > + <properties> >> > > + <log4jParentDir>${basedir}/..</log4jParentDir> >> > > + <projectDir>/scala_2.13</projectDir> >> > > + <scala.version>2.13.0-M2</scala.version> >> > > + <scala.maven.plugin.version>3.3.1</scala.maven.plugin.version> >> > > + <maven.compiler.source>1.8</maven.compiler.source> >> > > + <maven.compiler.target>1.8</maven.compiler.target> >> > > + </properties> >> > > + <dependencies> >> > > + <dependency> >> > > + <groupId>org.apache.logging.log4j</groupId> >> > > + <artifactId>log4j-api</artifactId> >> > > + </dependency> >> > > + <dependency> >> > > + <groupId>org.scala-lang</groupId> >> > > + <artifactId>scala-library</artifactId> >> > > + <version>${scala.version}</version> >> > > + </dependency> >> > > + <dependency> >> > > + <groupId>org.scala-lang</groupId> >> > > + <artifactId>scala-reflect</artifactId> >> > > + <version>${scala.version}</version> >> > > + </dependency> >> > > + <dependency> >> > > + <groupId>org.apache.logging.log4j</groupId> >> > > + <artifactId>log4j-api</artifactId> >> > > + <type>test-jar</type> >> > > + <scope>test</scope> >> > > + </dependency> >> > > + <dependency> >> > > + <groupId>junit</groupId> >> > > + <artifactId>junit</artifactId> >> > > + <scope>test</scope> >> > > + </dependency> >> > > + <dependency> >> > > + <groupId>org.scalatest</groupId> >> > > + <artifactId>scalatest_2.13.0-M2</artifactId> >> > > + <version>3.0.4</version> >> > > + <scope>test</scope> >> > > + </dependency> >> > > + <dependency> >> > > + <groupId>org.mockito</groupId> >> > > + <artifactId>mockito-core</artifactId> >> > > + <version>1.10.19</version> >> > > + <scope>test</scope> >> > > + </dependency> >> > > + </dependencies> >> > > + <build> >> > > + <sourceDirectory>src/main/scala</sourceDirectory> >> > > + <testSourceDirectory>src/test/scala</testSourceDirectory> >> > > + <plugins> >> > > + <plugin> >> > > + <groupId>net.alchim31.maven</groupId> >> > > + <artifactId>scala-maven-plugin</artifactId> >> > > + <version>${scala.maven.plugin.version}</version> >> > > + <executions> >> > > + <execution> >> > > + <goals> >> > > + <goal>compile</goal> >> > > + <goal>testCompile</goal> >> > > + <goal>doc-jar</goal> >> > > + </goals> >> > > + </execution> >> > > + </executions> >> > > + <configuration> >> > > + <args> >> > > + <arg>-feature</arg> >> > > + <arg>-unchecked</arg> >> > > + <arg>-deprecation</arg> >> > > + </args> >> > > + </configuration> >> > > + </plugin> >> > > + <plugin> >> > > + <groupId>org.apache.maven.plugins</groupId> >> > > + <artifactId>maven-surefire-plugin</artifactId> >> > > + </plugin> >> > > + <plugin> >> > > + <groupId>org.apache.felix</groupId> >> > > + <artifactId>maven-bundle-plugin</artifactId> >> > > + </plugin> >> > > + </plugins> >> > > + </build> >> > > + <reporting> >> > > + <plugins> >> > > + <plugin> >> > > + <groupId>org.apache.maven.plugins</groupId> >> > > + <artifactId>maven-changes-plugin</artifactId> >> > > + <version>${changes.plugin.version}</version> >> > > + <reportSets> >> > > + <reportSet> >> > > + <reports> >> > > + <report>changes-report</report> >> > > + </reports> >> > > + </reportSet> >> > > + </reportSets> >> > > + <configuration> >> > > + <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</ >> > > issueLinkTemplate> >> > > + <useJql>true</useJql> >> > > + </configuration> >> > > + </plugin> >> > > + <plugin> >> > > + <groupId>org.apache.maven.plugins</groupId> >> > > + <artifactId>maven-pmd-plugin</artifactId> >> > > + <version>${pmd.plugin.version}</version> >> > > + <configuration> >> > > + <targetJdk>${maven.compiler.target}</targetJdk> >> > > + </configuration> >> > > + </plugin> >> > > + <plugin> >> > > + <groupId>net.alchim31.maven</groupId> >> > > + <artifactId>scala-maven-plugin</artifactId> >> > > + <version>${scala.maven.plugin.version}</version> >> > > + </plugin> >> > > + </plugins> >> > > + </reporting> >> > > +</project> >> > > >> > > http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > blob/184045cb/log4j-api-scala_2.13/src/main/scala/org/ >> > > apache/logging/log4j/scala/Logger.scala >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > log4j/scala/Logger.scala >> > > b/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > > log4j/scala/Logger.scala >> > > new file mode 100644 >> > > index 0000000..b42cd5a >> > > --- /dev/null >> > > +++ b/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > > log4j/scala/Logger.scala >> > > @@ -0,0 +1,592 @@ >> > > +/* >> > > + * 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 >> > > + >> > > +import org.apache.logging.log4j.message.{EntryMessage, Message, >> > > MessageFactory2} >> > > +import org.apache.logging.log4j.spi.ExtendedLogger >> > > +import org.apache.logging.log4j.{Level, LogManager, Marker} >> > > + >> > > +import scala.language.experimental.macros >> > > + >> > > +/** >> > > + * Factory for [[Logger]]s. >> > > + * >> > > + * The [[Logging]] trait provides a simple way to get a properly >> named >> > > logger into a class. >> > > + */ >> > > +object Logger { >> > > + >> > > + final val FQCN = getClass.getName >> > > + >> > > + /** >> > > + * Create a properly named [[Logger]] for a given class. >> > > + * >> > > + * @param clazz the class >> > > + */ >> > > + def apply(clazz: Class[_]): Logger = Logger(LogManager.getContext( >> > clazz.getClassLoader, >> > > false).getLogger(clazz.getName)) >> > > + >> > > + /** >> > > + * Create a [[Logger]] wrapping the given Log4j logger. >> > > + * >> > > + * @param delegate the Log4j logger to wrap >> > > + */ >> > > + def apply(delegate: ExtendedLogger): Logger = new Logger(delegate) >> > > + >> > > +} >> > > + >> > > +/** >> > > + * Scala wrapper for the Log4j `Logger` interface. >> > > + * >> > > + * Frequently the purpose of logging is to provide information about >> > > what is happening in the system, >> > > + * which requires including information about the objects being >> > > manipulated. In Scala, you can use >> > > + * [[http://docs.scala-lang.org/overviews/core/string- >> > interpolation.html >> > > string interpolation]] >> > > + * to achieve this: >> > > + * >> > > + * {{{ >> > > + * logger.debug(s"Logging in user ${user.getName} with birthday >> > > ${user.calcBirthday}") >> > > + * }}} >> > > + * >> > > + * Since this wrapper is implemented with macros, the String >> > > construction and method invocations >> > > + * will only occur when debug logging is enabled. >> > > + */ >> > > +class Logger private(val delegate: ExtendedLogger) extends AnyVal { >> > > + >> > > + def fatal(marker: Marker, message: Message): Unit = >> > > + macro LoggerMacro.fatalMarkerMsg >> > > + >> > > + def fatal(marker: Marker, message: CharSequence): Unit = >> > > + macro LoggerMacro.fatalMarkerCseq >> > > + >> > > + def fatal(marker: Marker, message: AnyRef): Unit = >> > > + macro LoggerMacro.fatalMarkerObject >> > > + >> > > + def fatal(marker: Marker, message: Message, cause: Throwable): >> Unit = >> > > + macro LoggerMacro.fatalMarkerMsgThrowable >> > > + >> > > + def fatal(marker: Marker, message: CharSequence, cause: Throwable): >> > > Unit = >> > > + macro LoggerMacro.fatalMarkerCseqThrowable >> > > + >> > > + def fatal(marker: Marker, message: AnyRef, cause: Throwable): Unit >> = >> > > + macro LoggerMacro.fatalMarkerObjectThrowable >> > > + >> > > + def fatal(message: Message): Unit = >> > > + macro LoggerMacro.fatalMsg >> > > + >> > > + def fatal(message: CharSequence): Unit = >> > > + macro LoggerMacro.fatalCseq >> > > + >> > > + def fatal(message: AnyRef): Unit = >> > > + macro LoggerMacro.fatalObject >> > > + >> > > + def fatal(message: Message, cause: Throwable): Unit = >> > > + macro LoggerMacro.fatalMsgThrowable >> > > + >> > > + def fatal(message: CharSequence, cause: Throwable): Unit = >> > > + macro LoggerMacro.fatalCseqThrowable >> > > + >> > > + def fatal(message: AnyRef, cause: Throwable): Unit = >> > > + macro LoggerMacro.fatalObjectThrowable >> > > + >> > > + >> > > + def error(marker: Marker, message: Message): Unit = >> > > + macro LoggerMacro.errorMarkerMsg >> > > + >> > > + def error(marker: Marker, message: CharSequence): Unit = >> > > + macro LoggerMacro.errorMarkerCseq >> > > + >> > > + def error(marker: Marker, message: AnyRef): Unit = >> > > + macro LoggerMacro.errorMarkerObject >> > > + >> > > + def error(marker: Marker, message: Message, cause: Throwable): >> Unit = >> > > + macro LoggerMacro.errorMarkerMsgThrowable >> > > + >> > > + def error(marker: Marker, message: CharSequence, cause: Throwable): >> > > Unit = >> > > + macro LoggerMacro.errorMarkerCseqThrowable >> > > + >> > > + def error(marker: Marker, message: AnyRef, cause: Throwable): Unit >> = >> > > + macro LoggerMacro.errorMarkerObjectThrowable >> > > + >> > > + def error(message: Message): Unit = >> > > + macro LoggerMacro.errorMsg >> > > + >> > > + def error(message: CharSequence): Unit = >> > > + macro LoggerMacro.errorCseq >> > > + >> > > + def error(message: AnyRef): Unit = >> > > + macro LoggerMacro.errorObject >> > > + >> > > + def error(message: Message, cause: Throwable): Unit = >> > > + macro LoggerMacro.errorMsgThrowable >> > > + >> > > + def error(message: CharSequence, cause: Throwable): Unit = >> > > + macro LoggerMacro.errorCseqThrowable >> > > + >> > > + def error(message: AnyRef, cause: Throwable): Unit = >> > > + macro LoggerMacro.errorObjectThrowable >> > > + >> > > + >> > > + def warn(marker: Marker, message: Message): Unit = >> > > + macro LoggerMacro.warnMarkerMsg >> > > + >> > > + def warn(marker: Marker, message: CharSequence): Unit = >> > > + macro LoggerMacro.warnMarkerCseq >> > > + >> > > + def warn(marker: Marker, message: AnyRef): Unit = >> > > + macro LoggerMacro.warnMarkerObject >> > > + >> > > + def warn(marker: Marker, message: Message, cause: Throwable): Unit >> = >> > > + macro LoggerMacro.warnMarkerMsgThrowable >> > > + >> > > + def warn(marker: Marker, message: CharSequence, cause: Throwable): >> > Unit >> > > = >> > > + macro LoggerMacro.warnMarkerCseqThrowable >> > > + >> > > + def warn(marker: Marker, message: AnyRef, cause: Throwable): Unit = >> > > + macro LoggerMacro.warnMarkerObjectThrowable >> > > + >> > > + def warn(message: Message): Unit = >> > > + macro LoggerMacro.warnMsg >> > > + >> > > + def warn(message: CharSequence): Unit = >> > > + macro LoggerMacro.warnCseq >> > > + >> > > + def warn(message: AnyRef): Unit = >> > > + macro LoggerMacro.warnObject >> > > + >> > > + def warn(message: Message, cause: Throwable): Unit = >> > > + macro LoggerMacro.warnMsgThrowable >> > > + >> > > + def warn(message: CharSequence, cause: Throwable): Unit = >> > > + macro LoggerMacro.warnCseqThrowable >> > > + >> > > + def warn(message: AnyRef, cause: Throwable): Unit = >> > > + macro LoggerMacro.warnObjectThrowable >> > > + >> > > + >> > > + def info(marker: Marker, message: Message): Unit = >> > > + macro LoggerMacro.infoMarkerMsg >> > > + >> > > + def info(marker: Marker, message: CharSequence): Unit = >> > > + macro LoggerMacro.infoMarkerCseq >> > > + >> > > + def info(marker: Marker, message: AnyRef): Unit = >> > > + macro LoggerMacro.infoMarkerObject >> > > + >> > > + def info(marker: Marker, message: Message, cause: Throwable): Unit >> = >> > > + macro LoggerMacro.infoMarkerMsgThrowable >> > > + >> > > + def info(marker: Marker, message: CharSequence, cause: Throwable): >> > Unit >> > > = >> > > + macro LoggerMacro.infoMarkerCseqThrowable >> > > + >> > > + def info(marker: Marker, message: AnyRef, cause: Throwable): Unit = >> > > + macro LoggerMacro.infoMarkerObjectThrowable >> > > + >> > > + def info(message: Message): Unit = >> > > + macro LoggerMacro.infoMsg >> > > + >> > > + def info(message: CharSequence): Unit = >> > > + macro LoggerMacro.infoCseq >> > > + >> > > + def info(message: AnyRef): Unit = >> > > + macro LoggerMacro.infoObject >> > > + >> > > + def info(message: Message, cause: Throwable): Unit = >> > > + macro LoggerMacro.infoMsgThrowable >> > > + >> > > + def info(message: CharSequence, cause: Throwable): Unit = >> > > + macro LoggerMacro.infoCseqThrowable >> > > + >> > > + def info(message: AnyRef, cause: Throwable): Unit = >> > > + macro LoggerMacro.infoObjectThrowable >> > > + >> > > + >> > > + def debug(marker: Marker, message: Message): Unit = >> > > + macro LoggerMacro.debugMarkerMsg >> > > + >> > > + def debug(marker: Marker, message: CharSequence): Unit = >> > > + macro LoggerMacro.debugMarkerCseq >> > > + >> > > + def debug(marker: Marker, message: AnyRef): Unit = >> > > + macro LoggerMacro.debugMarkerObject >> > > + >> > > + def debug(marker: Marker, message: Message, cause: Throwable): >> Unit = >> > > + macro LoggerMacro.debugMarkerMsgThrowable >> > > + >> > > + def debug(marker: Marker, message: CharSequence, cause: Throwable): >> > > Unit = >> > > + macro LoggerMacro.debugMarkerCseqThrowable >> > > + >> > > + def debug(marker: Marker, message: AnyRef, cause: Throwable): Unit >> = >> > > + macro LoggerMacro.debugMarkerObjectThrowable >> > > + >> > > + def debug(message: Message): Unit = >> > > + macro LoggerMacro.debugMsg >> > > + >> > > + def debug(message: CharSequence): Unit = >> > > + macro LoggerMacro.debugCseq >> > > + >> > > + def debug(message: AnyRef): Unit = >> > > + macro LoggerMacro.debugObject >> > > + >> > > + def debug(message: Message, cause: Throwable): Unit = >> > > + macro LoggerMacro.debugMsgThrowable >> > > + >> > > + def debug(message: CharSequence, cause: Throwable): Unit = >> > > + macro LoggerMacro.debugCseqThrowable >> > > + >> > > + def debug(message: AnyRef, cause: Throwable): Unit = >> > > + macro LoggerMacro.debugObjectThrowable >> > > + >> > > + >> > > + def trace(marker: Marker, message: Message): Unit = >> > > + macro LoggerMacro.traceMarkerMsg >> > > + >> > > + def trace(marker: Marker, message: CharSequence): Unit = >> > > + macro LoggerMacro.traceMarkerCseq >> > > + >> > > + def trace(marker: Marker, message: AnyRef): Unit = >> > > + macro LoggerMacro.traceMarkerObject >> > > + >> > > + def trace(marker: Marker, message: Message, cause: Throwable): >> Unit = >> > > + macro LoggerMacro.traceMarkerMsgThrowable >> > > + >> > > + def trace(marker: Marker, message: CharSequence, cause: Throwable): >> > > Unit = >> > > + macro LoggerMacro.traceMarkerCseqThrowable >> > > + >> > > + def trace(marker: Marker, message: AnyRef, cause: Throwable): Unit >> = >> > > + macro LoggerMacro.traceMarkerObjectThrowable >> > > + >> > > + def trace(message: Message): Unit = >> > > + macro LoggerMacro.traceMsg >> > > + >> > > + def trace(message: CharSequence): Unit = >> > > + macro LoggerMacro.traceCseq >> > > + >> > > + def trace(message: AnyRef): Unit = >> > > + macro LoggerMacro.traceObject >> > > + >> > > + def trace(message: Message, cause: Throwable): Unit = >> > > + macro LoggerMacro.traceMsgThrowable >> > > + >> > > + def trace(message: CharSequence, cause: Throwable): Unit = >> > > + macro LoggerMacro.traceCseqThrowable >> > > + >> > > + def trace(message: AnyRef, cause: Throwable): Unit = >> > > + macro LoggerMacro.traceObjectThrowable >> > > + >> > > + >> > > + /** >> > > + * Logs a `Message` with the specific `Marker` at the given >> `Level`. >> > > + * >> > > + * @param level the logging level >> > > + * @param marker the marker data specific to this log statement >> > > + * @param message the message to be logged >> > > + */ >> > > + def apply(level: Level, marker: Marker, message: Message): Unit = >> > > + macro LoggerMacro.logMarkerMsg >> > > + >> > > + /** >> > > + * Logs a string with the specific `Marker` at the given `Level`. >> > > + * >> > > + * @param level the logging level >> > > + * @param marker the marker data specific to this log statement >> > > + * @param message the message to be logged >> > > + */ >> > > + def apply(level: Level, marker: Marker, message: CharSequence): >> Unit = >> > > + macro LoggerMacro.logMarkerCseq >> > > + >> > > + /** >> > > + * Logs an object with the specific `Marker` at the given `Level`. >> > > + * >> > > + * @param level the logging level >> > > + * @param marker the marker data specific to this log statement >> > > + * @param message the message to be logged >> > > + */ >> > > + def apply(level: Level, marker: Marker, message: AnyRef): Unit = >> > > + macro LoggerMacro.logMarkerObject >> > > + >> > > + /** >> > > + * Logs a `Message` with the specific `Marker` at the given >> `Level` >> > > including the stack trace >> > > + * of the given `Throwable`. >> > > + * >> > > + * @param level the logging level >> > > + * @param marker the marker data specific to this log statement >> > > + * @param message the message to be logged >> > > + * @param cause the cause >> > > + */ >> > > + def apply(level: Level, marker: Marker, message: Message, cause: >> > > Throwable): Unit = >> > > + macro LoggerMacro.logMarkerMsgThrowable >> > > + >> > > + /** >> > > + * Logs a string with the specific `Marker` at the given `Level` >> > > including the stack trace >> > > + * of the given `Throwable`. >> > > + * >> > > + * @param level the logging level >> > > + * @param marker the marker data specific to this log statement >> > > + * @param message the message to be logged >> > > + * @param cause the cause >> > > + */ >> > > + def apply(level: Level, marker: Marker, message: CharSequence, >> cause: >> > > Throwable): Unit = >> > > + macro LoggerMacro.logMarkerCseqThrowable >> > > + >> > > + /** >> > > + * Logs an object with the specific `Marker` at the given `Level` >> > > including the stack trace >> > > + * of the given `Throwable`. >> > > + * >> > > + * @param level the logging level >> > > + * @param marker the marker data specific to this log statement >> > > + * @param message the message to be logged >> > > + * @param cause the cause >> > > + */ >> > > + def apply(level: Level, marker: Marker, message: AnyRef, cause: >> > > Throwable): Unit = >> > > + macro LoggerMacro.logMarkerObjectThrowable >> > > + >> > > + /** >> > > + * Logs a `Message` at the given `Level`. >> > > + * >> > > + * @param level the logging level >> > > + * @param message the message to be logged >> > > + */ >> > > + def apply(level: Level, message: Message): Unit = >> > > + macro LoggerMacro.logMsg >> > > + >> > > + /** >> > > + * Logs a string at the given `Level`. >> > > + * >> > > + * @param level the logging level >> > > + * @param message the message to be logged >> > > + */ >> > > + def apply(level: Level, message: CharSequence): Unit = >> > > + macro LoggerMacro.logCseq >> > > + >> > > + /** >> > > + * Logs an object at the given `Level`. >> > > + * >> > > + * @param level the logging level >> > > + * @param message the message to be logged >> > > + */ >> > > + def apply(level: Level, message: AnyRef): Unit = >> > > + macro LoggerMacro.logObject >> > > + >> > > + /** >> > > + * Logs a `Message` at the given `Level` including the stack >> trace of >> > > the given `Throwable`. >> > > + * >> > > + * @param level the logging level >> > > + * @param message the message to be logged >> > > + * @param cause a `Throwable` >> > > + */ >> > > + def apply(level: Level, message: Message, cause: Throwable): Unit = >> > > + macro LoggerMacro.logMsgThrowable >> > > + >> > > + /** >> > > + * Logs a string at the given `Level` including the stack trace of >> > the >> > > given `Throwable`. >> > > + * >> > > + * @param level the logging level >> > > + * @param message the message to be logged >> > > + * @param cause a `Throwable` >> > > + */ >> > > + def apply(level: Level, message: CharSequence, cause: Throwable): >> > Unit = >> > > + macro LoggerMacro.logCseqThrowable >> > > + >> > > + /** >> > > + * Logs an object at the given `Level` including the stack trace >> of >> > > the given `Throwable`. >> > > + * >> > > + * @param level the logging level >> > > + * @param message the message to be logged >> > > + * @param cause a `Throwable` >> > > + */ >> > > + def apply(level: Level, message: AnyRef, cause: Throwable): Unit = >> > > + macro LoggerMacro.logObjectThrowable >> > > + >> > > + >> > > + /** >> > > + * Logs entry to a method. Used when the method in question has no >> > > parameters or when the parameters should not be >> > > + * logged. >> > > + * >> > > + * @return The built `EntryMessage` >> > > + */ >> > > + def traceEntry(): EntryMessage = >> > > + macro LoggerMacro.traceEntry >> > > + >> > > + /** >> > > + * Logs entry to a method along with its parameters. >> > > + * >> > > + * {{{ >> > > + * def doSomething(foo: String, bar: Int): Unit = { >> > > + * logger.traceEntry(foo, bar) >> > > + * // do something >> > > + * } >> > > + * }}} >> > > + * >> > > + * @param params the parameters to the method. >> > > + * @return The built `EntryMessage` >> > > + */ >> > > + def traceEntry(params: AnyRef*): EntryMessage = >> > > + macro LoggerMacro.traceEntryParams >> > > + >> > > + /** >> > > + * Logs entry to a method using a `Message` to describe the >> > parameters. >> > > + * >> > > + * {{{ >> > > + * def doSomething(foo: Request): Unit = { >> > > + * logger.traceEntry(JsonMessage(foo)) >> > > + * // do something >> > > + * } >> > > + * }}} >> > > + * >> > > + * @param message the message >> > > + * @return The built `EntryMessage` >> > > + */ >> > > + def traceEntry(message: Message): EntryMessage = >> > > + macro LoggerMacro.traceEntryMessage >> > > + >> > > + /** >> > > + * Logs exit from a method with no result. >> > > + */ >> > > + def traceExit(): Unit = >> > > + macro LoggerMacro.traceExit >> > > + >> > > + /** >> > > + * Logs exiting from a method with result. >> > > + * >> > > + * @param result The result being returned from the method call >> > > + * @return `result` >> > > + */ >> > > + def traceExit[R](result: R): R = >> > > + macro LoggerMacro.traceExitResult[R] >> > > + >> > > + /** >> > > + * Logs exiting from a method with no result. >> > > + * >> > > + * @param entryMessage the `EntryMessage` returned from one of the >> > > `traceEntry` methods >> > > + */ >> > > + def traceExit(entryMessage: EntryMessage): Unit = >> > > + macro LoggerMacro.traceExitEntryMessage >> > > + >> > > + /** >> > > + * Logs exiting from a method with result. >> > > + * >> > > + * {{{ >> > > + * def doSomething(foo: String, bar: Int): Int = { >> > > + * val entryMessage = logger.traceEntry(foo, bar) >> > > + * // do something >> > > + * traceExit(entryMessage, value) >> > > + * } >> > > + * }}} >> > > + * >> > > + * @param entryMessage the `EntryMessage` returned from one of the >> > > `traceEntry` methods >> > > + * @param result The result being returned from the method >> call >> > > + * @return `result` >> > > + */ >> > > + def traceExit[R](entryMessage: EntryMessage, result: R): R = >> > > + macro LoggerMacro.traceExitEntryMessageResult[R] >> > > + >> > > + /** >> > > + * Logs exiting from a method with result. Allows custom >> formatting >> > of >> > > the result. >> > > + * >> > > + * @param message the Message containing the formatted result >> > > + * @param result The result being returned from the method call. >> > > + * @return `result` >> > > + */ >> > > + def traceExit[R](message: Message, result: R): R = >> > > + macro LoggerMacro.traceExitMessageResult[R] >> > > + >> > > + /** >> > > + * Logs an exception or error to be thrown. >> > > + * >> > > + * {{{ >> > > + * throw logger.throwing(myException) >> > > + * }}} >> > > + * >> > > + * @param t the Throwable >> > > + * @return `t` >> > > + */ >> > > + def throwing[T <: Throwable](t: T): T = >> > > + macro LoggerMacro.throwing[T] >> > > + >> > > + /** >> > > + * Logs an exception or error to be thrown to a specific logging >> > level. >> > > + * >> > > + * {{{ >> > > + * throw logger.throwing(Level.DEBUG, myException) >> > > + * }}} >> > > + * >> > > + * @param level the logging Level. >> > > + * @param t the Throwable >> > > + * @return `t` >> > > + */ >> > > + def throwing[T <: Throwable](level: Level, t: T): T = >> > > + macro LoggerMacro.throwingLevel[T] >> > > + >> > > + /** >> > > + * Logs an exception or error that has been caught. >> > > + * >> > > + * @param t the Throwable. >> > > + */ >> > > + def catching(t: Throwable): Unit = >> > > + macro LoggerMacro.catching >> > > + >> > > + /** >> > > + * Logs an exception or error that has been caught to a specific >> > > logging level. >> > > + * >> > > + * @param level The logging Level. >> > > + * @param t The Throwable. >> > > + */ >> > > + def catching(level: Level, t: Throwable): Unit = >> > > + macro LoggerMacro.catchingLevel >> > > + >> > > + >> > > + /** Always logs a message at the specified level. It is the >> > > responsibility of the caller to ensure the specified >> > > + * level is enabled. >> > > + * >> > > + * Should normally not be used directly from application code, but >> > > needs to be public for access by macros. >> > > + * >> > > + * @param level log level >> > > + * @param marker marker or `null` >> > > + * @param message message >> > > + * @param cause cause or `null` >> > > + */ >> > > + def logMessage(level: Level, marker: Marker, message: Message, >> cause: >> > > Throwable): Unit = { >> > > + delegate.logMessage(Logger.FQCN, level, marker, message, cause) >> > > + } >> > > + >> > > + /** Always logs a message at the specified level. It is the >> > > responsibility of the caller to ensure the specified >> > > + * level is enabled. >> > > + * >> > > + * Should normally not be used directly from application code, but >> > > needs to be public for access by macros. >> > > + * >> > > + * @param level log level >> > > + * @param marker marker or `null` >> > > + * @param message message >> > > + * @param cause cause or `null` >> > > + */ >> > > + def logMessage(level: Level, marker: Marker, message: CharSequence, >> > > cause: Throwable): Unit = { >> > > + delegate.logMessage(Logger.FQCN, level, marker, >> > > delegate.getMessageFactory.asInstanceOf[MessageFactory2]. >> > newMessage(message), >> > > cause) >> > > + } >> > > + >> > > + /** Always logs a message at the specified level. It is the >> > > responsibility of the caller to ensure the specified >> > > + * level is enabled. >> > > + * >> > > + * Should normally not be used directly from application code, but >> > > needs to be public for access by macros. >> > > + * >> > > + * @param level log level >> > > + * @param marker marker or `null` >> > > + * @param message message >> > > + * @param cause cause or `null` >> > > + */ >> > > + def logMessage(level: Level, marker: Marker, message: AnyRef, >> cause: >> > > Throwable): Unit = { >> > > + delegate.logMessage(Logger.FQCN, level, marker, >> > > delegate.getMessageFactory.asInstanceOf[MessageFactory2]. >> > newMessage(message), >> > > cause) >> > > + } >> > > + >> > > +} >> > > >> > > http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > blob/184045cb/log4j-api-scala_2.13/src/main/scala/org/ >> > > apache/logging/log4j/scala/LoggerMacro.scala >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > log4j/scala/LoggerMacro.scala >> > > b/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > > log4j/scala/LoggerMacro.scala >> > > new file mode 100644 >> > > index 0000000..3b54db1 >> > > --- /dev/null >> > > +++ b/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > > log4j/scala/LoggerMacro.scala >> > > @@ -0,0 +1,425 @@ >> > > +/* >> > > + * 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 >> > > + >> > > +import org.apache.logging.log4j.message.{EntryMessage, Message} >> > > +import org.apache.logging.log4j.spi.AbstractLogger >> > > +import org.apache.logging.log4j.{Level, Marker} >> > > + >> > > +import scala.language.experimental.macros >> > > +import scala.reflect.macros.blackbox >> > > + >> > > +/** >> > > + * Inspired from [[https://github.com/typesafehub/scalalogging >> > > ScalaLogging]]. >> > > + */ >> > > +private object LoggerMacro { >> > > + >> > > + type LoggerContext = blackbox.Context { type PrefixType = Logger } >> > > + >> > > + >> > > + def fatalMarkerMsg(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[Message]) = >> > > + logMarkerMsg(c)(c.universe.reify(Level.FATAL), marker, message) >> > > + >> > > + def fatalMarkerCseq(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[CharSequence]) = >> > > + logMarkerCseq(c)(c.universe.reify(Level.FATAL), marker, message) >> > > + >> > > + def fatalMarkerObject(c: LoggerContext)(marker: c.Expr[Marker], >> > > message: c.Expr[AnyRef]) = >> > > + logMarkerObject(c)(c.universe.reify(Level.FATAL), marker, >> message) >> > > + >> > > + def fatalMarkerMsgThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[Message], cause: c.Expr[Throwable]) = >> > > + logMarkerMsgThrowable(c)(c.universe.reify(Level.FATAL), marker, >> > > message, cause) >> > > + >> > > + def fatalMarkerCseqThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[CharSequence], cause: c.Expr[Throwable]) = >> > > + logMarkerCseqThrowable(c)(c.universe.reify(Level.FATAL), marker, >> > > message, cause) >> > > + >> > > + def fatalMarkerObjectThrowable(c: LoggerContext)(marker: >> > > c.Expr[Marker], message: c.Expr[AnyRef], cause: c.Expr[Throwable]) = >> > > + logMarkerObjectThrowable(c)(c.universe.reify(Level.FATAL), >> marker, >> > > message, cause) >> > > + >> > > + def fatalMsg(c: LoggerContext)(message: c.Expr[Message]) = >> > > + logMsg(c)(c.universe.reify(Level.FATAL), message) >> > > + >> > > + def fatalCseq(c: LoggerContext)(message: c.Expr[CharSequence]) = >> > > + logCseq(c)(c.universe.reify(Level.FATAL), message) >> > > + >> > > + def fatalObject(c: LoggerContext)(message: c.Expr[AnyRef]) = >> > > + logObject(c)(c.universe.reify(Level.FATAL), message) >> > > + >> > > + def fatalMsgThrowable(c: LoggerContext)(message: c.Expr[Message], >> > > cause: c.Expr[Throwable]) = >> > > + logMsgThrowable(c)(c.universe.reify(Level.FATAL), message, >> cause) >> > > + >> > > + def fatalCseqThrowable(c: LoggerContext)(message: >> > c.Expr[CharSequence], >> > > cause: c.Expr[Throwable]) = >> > > + logCseqThrowable(c)(c.universe.reify(Level.FATAL), message, >> cause) >> > > + >> > > + def fatalObjectThrowable(c: LoggerContext)(message: c.Expr[AnyRef], >> > > cause: c.Expr[Throwable]) = >> > > + logObjectThrowable(c)(c.universe.reify(Level.FATAL), message, >> > cause) >> > > + >> > > + >> > > + def errorMarkerMsg(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[Message]) = >> > > + logMarkerMsg(c)(c.universe.reify(Level.ERROR), marker, message) >> > > + >> > > + def errorMarkerCseq(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[CharSequence]) = >> > > + logMarkerCseq(c)(c.universe.reify(Level.ERROR), marker, message) >> > > + >> > > + def errorMarkerObject(c: LoggerContext)(marker: c.Expr[Marker], >> > > message: c.Expr[AnyRef]) = >> > > + logMarkerObject(c)(c.universe.reify(Level.ERROR), marker, >> message) >> > > + >> > > + def errorMarkerMsgThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[Message], cause: c.Expr[Throwable]) = >> > > + logMarkerMsgThrowable(c)(c.universe.reify(Level.ERROR), marker, >> > > message, cause) >> > > + >> > > + def errorMarkerCseqThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[CharSequence], cause: c.Expr[Throwable]) = >> > > + logMarkerCseqThrowable(c)(c.universe.reify(Level.ERROR), marker, >> > > message, cause) >> > > + >> > > + def errorMarkerObjectThrowable(c: LoggerContext)(marker: >> > > c.Expr[Marker], message: c.Expr[AnyRef], cause: c.Expr[Throwable]) = >> > > + logMarkerObjectThrowable(c)(c.universe.reify(Level.ERROR), >> marker, >> > > message, cause) >> > > + >> > > + def errorMsg(c: LoggerContext)(message: c.Expr[Message]) = >> > > + logMsg(c)(c.universe.reify(Level.ERROR), message) >> > > + >> > > + def errorCseq(c: LoggerContext)(message: c.Expr[CharSequence]) = >> > > + logCseq(c)(c.universe.reify(Level.ERROR), message) >> > > + >> > > + def errorObject(c: LoggerContext)(message: c.Expr[AnyRef]) = >> > > + logObject(c)(c.universe.reify(Level.ERROR), message) >> > > + >> > > + def errorMsgThrowable(c: LoggerContext)(message: c.Expr[Message], >> > > cause: c.Expr[Throwable]) = >> > > + logMsgThrowable(c)(c.universe.reify(Level.ERROR), message, >> cause) >> > > + >> > > + def errorCseqThrowable(c: LoggerContext)(message: >> > c.Expr[CharSequence], >> > > cause: c.Expr[Throwable]) = >> > > + logCseqThrowable(c)(c.universe.reify(Level.ERROR), message, >> cause) >> > > + >> > > + def errorObjectThrowable(c: LoggerContext)(message: c.Expr[AnyRef], >> > > cause: c.Expr[Throwable]) = >> > > + logObjectThrowable(c)(c.universe.reify(Level.ERROR), message, >> > cause) >> > > + >> > > + >> > > + def warnMarkerMsg(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[Message]) = >> > > + logMarkerMsg(c)(c.universe.reify(Level.WARN), marker, message) >> > > + >> > > + def warnMarkerCseq(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[CharSequence]) = >> > > + logMarkerCseq(c)(c.universe.reify(Level.WARN), marker, message) >> > > + >> > > + def warnMarkerObject(c: LoggerContext)(marker: c.Expr[Marker], >> > message: >> > > c.Expr[AnyRef]) = >> > > + logMarkerObject(c)(c.universe.reify(Level.WARN), marker, >> message) >> > > + >> > > + def warnMarkerMsgThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[Message], cause: c.Expr[Throwable]) = >> > > + logMarkerMsgThrowable(c)(c.universe.reify(Level.WARN), marker, >> > > message, cause) >> > > + >> > > + def warnMarkerCseqThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[CharSequence], cause: c.Expr[Throwable]) = >> > > + logMarkerCseqThrowable(c)(c.universe.reify(Level.WARN), marker, >> > > message, cause) >> > > + >> > > + def warnMarkerObjectThrowable(c: LoggerContext)(marker: >> > c.Expr[Marker], >> > > message: c.Expr[AnyRef], cause: c.Expr[Throwable]) = >> > > + logMarkerObjectThrowable(c)(c.universe.reify(Level.WARN), >> marker, >> > > message, cause) >> > > + >> > > + def warnMsg(c: LoggerContext)(message: c.Expr[Message]) = >> > > + logMsg(c)(c.universe.reify(Level.WARN), message) >> > > + >> > > + def warnCseq(c: LoggerContext)(message: c.Expr[CharSequence]) = >> > > + logCseq(c)(c.universe.reify(Level.WARN), message) >> > > + >> > > + def warnObject(c: LoggerContext)(message: c.Expr[AnyRef]) = >> > > + logObject(c)(c.universe.reify(Level.WARN), message) >> > > + >> > > + def warnMsgThrowable(c: LoggerContext)(message: c.Expr[Message], >> > cause: >> > > c.Expr[Throwable]) = >> > > + logMsgThrowable(c)(c.universe.reify(Level.WARN), message, cause) >> > > + >> > > + def warnCseqThrowable(c: LoggerContext)(message: >> c.Expr[CharSequence], >> > > cause: c.Expr[Throwable]) = >> > > + logCseqThrowable(c)(c.universe.reify(Level.WARN), message, >> cause) >> > > + >> > > + def warnObjectThrowable(c: LoggerContext)(message: c.Expr[AnyRef], >> > > cause: c.Expr[Throwable]) = >> > > + logObjectThrowable(c)(c.universe.reify(Level.WARN), message, >> cause) >> > > + >> > > + >> > > + def infoMarkerMsg(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[Message]) = >> > > + logMarkerMsg(c)(c.universe.reify(Level.INFO), marker, message) >> > > + >> > > + def infoMarkerCseq(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[CharSequence]) = >> > > + logMarkerCseq(c)(c.universe.reify(Level.INFO), marker, message) >> > > + >> > > + def infoMarkerObject(c: LoggerContext)(marker: c.Expr[Marker], >> > message: >> > > c.Expr[AnyRef]) = >> > > + logMarkerObject(c)(c.universe.reify(Level.INFO), marker, >> message) >> > > + >> > > + def infoMarkerMsgThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[Message], cause: c.Expr[Throwable]) = >> > > + logMarkerMsgThrowable(c)(c.universe.reify(Level.INFO), marker, >> > > message, cause) >> > > + >> > > + def infoMarkerCseqThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[CharSequence], cause: c.Expr[Throwable]) = >> > > + logMarkerCseqThrowable(c)(c.universe.reify(Level.INFO), marker, >> > > message, cause) >> > > + >> > > + def infoMarkerObjectThrowable(c: LoggerContext)(marker: >> > c.Expr[Marker], >> > > message: c.Expr[AnyRef], cause: c.Expr[Throwable]) = >> > > + logMarkerObjectThrowable(c)(c.universe.reify(Level.INFO), >> marker, >> > > message, cause) >> > > + >> > > + def infoMsg(c: LoggerContext)(message: c.Expr[Message]) = >> > > + logMsg(c)(c.universe.reify(Level.INFO), message) >> > > + >> > > + def infoCseq(c: LoggerContext)(message: c.Expr[CharSequence]) = >> > > + logCseq(c)(c.universe.reify(Level.INFO), message) >> > > + >> > > + def infoObject(c: LoggerContext)(message: c.Expr[AnyRef]) = >> > > + logObject(c)(c.universe.reify(Level.INFO), message) >> > > + >> > > + def infoMsgThrowable(c: LoggerContext)(message: c.Expr[Message], >> > cause: >> > > c.Expr[Throwable]) = >> > > + logMsgThrowable(c)(c.universe.reify(Level.INFO), message, cause) >> > > + >> > > + def infoCseqThrowable(c: LoggerContext)(message: >> c.Expr[CharSequence], >> > > cause: c.Expr[Throwable]) = >> > > + logCseqThrowable(c)(c.universe.reify(Level.INFO), message, >> cause) >> > > + >> > > + def infoObjectThrowable(c: LoggerContext)(message: c.Expr[AnyRef], >> > > cause: c.Expr[Throwable]) = >> > > + logObjectThrowable(c)(c.universe.reify(Level.INFO), message, >> cause) >> > > + >> > > + >> > > + def debugMarkerMsg(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[Message]) = >> > > + logMarkerMsg(c)(c.universe.reify(Level.DEBUG), marker, message) >> > > + >> > > + def debugMarkerCseq(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[CharSequence]) = >> > > + logMarkerCseq(c)(c.universe.reify(Level.DEBUG), marker, message) >> > > + >> > > + def debugMarkerObject(c: LoggerContext)(marker: c.Expr[Marker], >> > > message: c.Expr[AnyRef]) = >> > > + logMarkerObject(c)(c.universe.reify(Level.DEBUG), marker, >> message) >> > > + >> > > + def debugMarkerMsgThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[Message], cause: c.Expr[Throwable]) = >> > > + logMarkerMsgThrowable(c)(c.universe.reify(Level.DEBUG), marker, >> > > message, cause) >> > > + >> > > + def debugMarkerCseqThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[CharSequence], cause: c.Expr[Throwable]) = >> > > + logMarkerCseqThrowable(c)(c.universe.reify(Level.DEBUG), marker, >> > > message, cause) >> > > + >> > > + def debugMarkerObjectThrowable(c: LoggerContext)(marker: >> > > c.Expr[Marker], message: c.Expr[AnyRef], cause: c.Expr[Throwable]) = >> > > + logMarkerObjectThrowable(c)(c.universe.reify(Level.DEBUG), >> marker, >> > > message, cause) >> > > + >> > > + def debugMsg(c: LoggerContext)(message: c.Expr[Message]) = >> > > + logMsg(c)(c.universe.reify(Level.DEBUG), message) >> > > + >> > > + def debugCseq(c: LoggerContext)(message: c.Expr[CharSequence]) = >> > > + logCseq(c)(c.universe.reify(Level.DEBUG), message) >> > > + >> > > + def debugObject(c: LoggerContext)(message: c.Expr[AnyRef]) = >> > > + logObject(c)(c.universe.reify(Level.DEBUG), message) >> > > + >> > > + def debugMsgThrowable(c: LoggerContext)(message: c.Expr[Message], >> > > cause: c.Expr[Throwable]) = >> > > + logMsgThrowable(c)(c.universe.reify(Level.DEBUG), message, >> cause) >> > > + >> > > + def debugCseqThrowable(c: LoggerContext)(message: >> > c.Expr[CharSequence], >> > > cause: c.Expr[Throwable]) = >> > > + logCseqThrowable(c)(c.universe.reify(Level.DEBUG), message, >> cause) >> > > + >> > > + def debugObjectThrowable(c: LoggerContext)(message: c.Expr[AnyRef], >> > > cause: c.Expr[Throwable]) = >> > > + logObjectThrowable(c)(c.universe.reify(Level.DEBUG), message, >> > cause) >> > > + >> > > + >> > > + def traceMarkerMsg(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[Message]) = >> > > + logMarkerMsg(c)(c.universe.reify(Level.TRACE), marker, message) >> > > + >> > > + def traceMarkerCseq(c: LoggerContext)(marker: c.Expr[Marker], >> message: >> > > c.Expr[CharSequence]) = >> > > + logMarkerCseq(c)(c.universe.reify(Level.TRACE), marker, message) >> > > + >> > > + def traceMarkerObject(c: LoggerContext)(marker: c.Expr[Marker], >> > > message: c.Expr[AnyRef]) = >> > > + logMarkerObject(c)(c.universe.reify(Level.TRACE), marker, >> message) >> > > + >> > > + def traceMarkerMsgThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[Message], cause: c.Expr[Throwable]) = >> > > + logMarkerMsgThrowable(c)(c.universe.reify(Level.TRACE), marker, >> > > message, cause) >> > > + >> > > + def traceMarkerCseqThrowable(c: LoggerContext)(marker: >> c.Expr[Marker], >> > > message: c.Expr[CharSequence], cause: c.Expr[Throwable]) = >> > > + logMarkerCseqThrowable(c)(c.universe.reify(Level.TRACE), marker, >> > > message, cause) >> > > + >> > > + def traceMarkerObjectThrowable(c: LoggerContext)(marker: >> > > c.Expr[Marker], message: c.Expr[AnyRef], cause: c.Expr[Throwable]) = >> > > + logMarkerObjectThrowable(c)(c.universe.reify(Level.TRACE), >> marker, >> > > message, cause) >> > > + >> > > + def traceMsg(c: LoggerContext)(message: c.Expr[Message]) = >> > > + logMsg(c)(c.universe.reify(Level.TRACE), message) >> > > + >> > > + def traceCseq(c: LoggerContext)(message: c.Expr[CharSequence]) = >> > > + logCseq(c)(c.universe.reify(Level.TRACE), message) >> > > + >> > > + def traceObject(c: LoggerContext)(message: c.Expr[AnyRef]) = >> > > + logObject(c)(c.universe.reify(Level.TRACE), message) >> > > + >> > > + def traceMsgThrowable(c: LoggerContext)(message: c.Expr[Message], >> > > cause: c.Expr[Throwable]) = >> > > + logMsgThrowable(c)(c.universe.reify(Level.TRACE), message, >> cause) >> > > + >> > > + def traceCseqThrowable(c: LoggerContext)(message: >> > c.Expr[CharSequence], >> > > cause: c.Expr[Throwable]) = >> > > + logCseqThrowable(c)(c.universe.reify(Level.TRACE), message, >> cause) >> > > + >> > > + def traceObjectThrowable(c: LoggerContext)(message: c.Expr[AnyRef], >> > > cause: c.Expr[Throwable]) = >> > > + logObjectThrowable(c)(c.universe.reify(Level.TRACE), message, >> > cause) >> > > + >> > > + >> > > + def logMarkerMsg(c: LoggerContext)(level: c.Expr[Level], marker: >> > > c.Expr[Marker], message: c.Expr[Message]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice, >> > > marker.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, marker.splice, >> > > message.splice, null) >> > > + } >> > > + ) >> > > + >> > > + def logMarkerCseq(c: LoggerContext)(level: c.Expr[Level], marker: >> > > c.Expr[Marker], message: c.Expr[CharSequence]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice, >> > > marker.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, marker.splice, >> > > message.splice, null) >> > > + } >> > > + ) >> > > + >> > > + def logMarkerObject(c: LoggerContext)(level: c.Expr[Level], marker: >> > > c.Expr[Marker], message: c.Expr[AnyRef]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice, >> > > marker.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, marker.splice, >> > > message.splice, null) >> > > + } >> > > + ) >> > > + >> > > + def logMarkerMsgThrowable(c: LoggerContext)(level: c.Expr[Level], >> > > marker: c.Expr[Marker], message: c.Expr[Message], cause: >> > c.Expr[Throwable]) >> > > = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice, >> > > marker.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, marker.splice, >> > > message.splice, cause.splice) >> > > + } >> > > + ) >> > > + >> > > + def logMarkerCseqThrowable(c: LoggerContext)(level: c.Expr[Level], >> > > marker: c.Expr[Marker], message: c.Expr[CharSequence], cause: >> > > c.Expr[Throwable]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice, >> > > marker.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, marker.splice, >> > > message.splice, cause.splice) >> > > + } >> > > + ) >> > > + >> > > + def logMarkerObjectThrowable(c: LoggerContext)(level: >> c.Expr[Level], >> > > marker: c.Expr[Marker], message: c.Expr[AnyRef], cause: >> > c.Expr[Throwable]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice, >> > > marker.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, marker.splice, >> > > message.splice, cause.splice) >> > > + } >> > > + ) >> > > + >> > > + def logMsg(c: LoggerContext)(level: c.Expr[Level], message: >> > > c.Expr[Message]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, null, >> message.splice, >> > > null) >> > > + } >> > > + ) >> > > + >> > > + def logCseq(c: LoggerContext)(level: c.Expr[Level], message: >> > > c.Expr[CharSequence]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, null, >> message.splice, >> > > null) >> > > + } >> > > + ) >> > > + >> > > + def logObject(c: LoggerContext)(level: c.Expr[Level], message: >> > > c.Expr[AnyRef]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, null, >> message.splice, >> > > null) >> > > + } >> > > + ) >> > > + >> > > + def logMsgThrowable(c: LoggerContext)(level: c.Expr[Level], >> message: >> > > c.Expr[Message], cause: c.Expr[Throwable]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, null, >> message.splice, >> > > cause.splice) >> > > + } >> > > + ) >> > > + >> > > + def logCseqThrowable(c: LoggerContext)(level: c.Expr[Level], >> message: >> > > c.Expr[CharSequence], cause: c.Expr[Throwable]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, null, >> message.splice, >> > > cause.splice) >> > > + } >> > > + ) >> > > + >> > > + def logObjectThrowable(c: LoggerContext)(level: c.Expr[Level], >> > message: >> > > c.Expr[AnyRef], cause: c.Expr[Throwable]) = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(level.splice)) { >> > > + c.prefix.splice.logMessage(level.splice, null, >> message.splice, >> > > cause.splice) >> > > + } >> > > + ) >> > > + >> > > + >> > > + def traceEntry(c: LoggerContext)(): c.Expr[EntryMessage] = >> > > + c.universe.reify( >> > > + c.prefix.splice.delegate.traceEntry() >> > > + ) >> > > + >> > > + def traceEntryParams(c: LoggerContext)(params: c.Expr[AnyRef]*): >> > > c.Expr[EntryMessage] = { >> > > + import c.universe._ >> > > + val isEnabled = Apply( >> > > + Select(Select(c.prefix.tree, TermName("delegate")), >> > > TermName("isEnabled")), >> > > + List( >> > > + reify(Level.TRACE).tree, >> > > + reify(AbstractLogger.ENTRY_MARKER).tree, >> > > + reify(null: AnyRef).tree, >> > > + reify(null).tree >> > > + ) >> > > + ) >> > > + >> > > + val log = Apply( >> > > + Select(Select(c.prefix.tree, TermName("delegate")), >> > > TermName("traceEntry")), >> > > + reify(null: String).tree :: (params map (_.tree)).toList >> > > + ) >> > > + c.Expr[EntryMessage](If(isEnabled, log, reify(null).tree)) >> > > + } >> > > + >> > > + >> > > + def traceEntryMessage(c: LoggerContext)(message: c.Expr[Message]): >> > > c.Expr[EntryMessage] = >> > > + c.universe.reify( >> > > + if (c.prefix.splice.delegate.isEnabled(Level.TRACE, >> > > AbstractLogger.ENTRY_MARKER, null: AnyRef, null)) { >> > > + c.prefix.splice.delegate.traceEntry(message.splice) // TODO >> > > should not do ifEnabled check >> > > + } else { >> > > + null >> > > + } >> > > + ) >> > > + >> > > + def traceExit(c: LoggerContext)(): c.Expr[Unit] = >> > > + c.universe.reify( >> > > + c.prefix.splice.delegate.traceExit() >> > > + ) >> > > + >> > > + def traceExitResult[R: c.WeakTypeTag](c: LoggerContext)(result: >> > > c.Expr[R]): c.Expr[R] = >> > > + c.universe.reify( >> > > + c.prefix.splice.delegate.traceExit(result.splice) >> > > + ) >> > > + >> > > + def traceExitEntryMessage(c: LoggerContext)(entryMessage: >> > > c.Expr[EntryMessage]): c.Expr[Unit] = >> > > + c.universe.reify( >> > > + c.prefix.splice.delegate.traceExit(entryMessage.splice) >> > > + ) >> > > + >> > > + def traceExitEntryMessageResult[R: c.WeakTypeTag](c: >> > > LoggerContext)(entryMessage: c.Expr[EntryMessage], result: c.Expr[R]): >> > > c.Expr[R] = >> > > + c.universe.reify( >> > > + c.prefix.splice.delegate.traceExit(entryMessage.splice, >> > > result.splice) >> > > + ) >> > > + >> > > + def traceExitMessageResult[R: c.WeakTypeTag](c: >> > LoggerContext)(message: >> > > c.Expr[Message], result: c.Expr[R]): c.Expr[R] = >> > > + c.universe.reify( >> > > + { >> > > + if (message.splice != null && c.prefix.splice.delegate. >> > isEnabled(Level.TRACE, >> > > AbstractLogger.EXIT_MARKER, message.splice, null)) { >> > > + c.prefix.splice.delegate.traceExit(message.splice, >> > > result.splice) // TODO should not do ifEnabled check >> > > + } >> > > + result.splice >> > > + } >> > > + ) >> > > + >> > > + def throwing[T <: Throwable: c.WeakTypeTag](c: LoggerContext)(t: >> > > c.Expr[T]): c.Expr[T] = >> > > + c.universe.reify( >> > > + c.prefix.splice.delegate.throwing(t.splice) >> > > + ) >> > > + >> > > + def throwingLevel[T <: Throwable: c.WeakTypeTag](c: >> > > LoggerContext)(level: c.Expr[Level], t: c.Expr[T]): c.Expr[T] = >> > > + c.universe.reify( >> > > + c.prefix.splice.delegate.throwing(level.splice, t.splice) >> > > + ) >> > > + >> > > + def catching(c: LoggerContext)(t: c.Expr[Throwable]): c.Expr[Unit] >> = >> > > + c.universe.reify( >> > > + c.prefix.splice.delegate.catching(t.splice) >> > > + ) >> > > + >> > > + def catchingLevel(c: LoggerContext)(level: c.Expr[Level], t: >> > > c.Expr[Throwable]): c.Expr[Unit] = >> > > + c.universe.reify( >> > > + c.prefix.splice.delegate.catching(level.splice, t.splice) >> > > + ) >> > > + >> > > +} >> > > >> > > http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > blob/184045cb/log4j-api-scala_2.13/src/main/scala/org/ >> > > apache/logging/log4j/scala/Logging.scala >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > log4j/scala/Logging.scala >> > > b/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > > log4j/scala/Logging.scala >> > > new file mode 100644 >> > > index 0000000..b017de7 >> > > --- /dev/null >> > > +++ b/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > > log4j/scala/Logging.scala >> > > @@ -0,0 +1,30 @@ >> > > +/* >> > > + * 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 >> > > + >> > > +/** >> > > + * Mix in this trait into classes from which you want to log, >> > > + * give you a `logger` value with a [[Logger]] named according to >> the >> > > class. >> > > + */ >> > > +trait Logging { >> > > + >> > > + /** >> > > + * A [[Logger]] named according to the class. >> > > + */ >> > > + protected val logger: Logger = Logger(getClass) >> > > + >> > > +} >> > > \ No newline at end of file >> > > >> > > http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > blob/184045cb/log4j-api-scala_2.13/src/main/scala/org/ >> > > apache/logging/log4j/scala/LoggingContext.scala >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > > log4j/scala/LoggingContext.scala b/log4j-api-scala_2.13/src/ >> > > main/scala/org/apache/logging/log4j/scala/LoggingContext.scala >> > > new file mode 100644 >> > > index 0000000..79efecc >> > > --- /dev/null >> > > +++ b/log4j-api-scala_2.13/src/main/scala/org/apache/logging/ >> > > log4j/scala/LoggingContext.scala >> > > @@ -0,0 +1,84 @@ >> > > +/* >> > > + * 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 >> > > + >> > > +import org.apache.logging.log4j.ThreadContext >> > > + >> > > +import scala.collection.JavaConverters._ >> > > +import scala.collection.{immutable, mutable} >> > > + >> > > +/** Manages the context data (context map, MDC) that is added to log >> > > events. >> > > + * >> > > + * A wrapper around `org.apache.logging.log4j.ThreadContext`. >> > > + */ >> > > +object LoggingContext extends mutable.Map[String, String] { >> > > + >> > > + override def +=(kv: (String, String)): LoggingContext.this.type = { >> > > + ThreadContext.put(kv._1, kv._2) >> > > + this >> > > + } >> > > + >> > > + override def +=(elem1: (String, String), elem2: (String, String), >> > > elems: (String, String)*): LoggingContext.this.type = { >> > > + val builder = immutable.Map.newBuilder[String,String] >> > > + builder += elem1 >> > > + builder += elem2 >> > > + builder ++= elems >> > > + ThreadContext.putAll(builder.result.asJava) >> > > + this >> > > + } >> > > + >> > > + override def ++=(xs: TraversableOnce[(String, String)]): >> > > LoggingContext.this.type = { >> > > + ThreadContext.putAll(xs.toMap.asJava) >> > > + this >> > > + } >> > > + >> > > + override def -=(key: String): LoggingContext.this.type = { >> > > + ThreadContext.remove(key) >> > > + this >> > > + } >> > > + >> > > + override def -=(elem1: String, elem2: String, elems: String*): >> > > LoggingContext.this.type = { >> > > + val builder = immutable.Seq.newBuilder[String] >> > > + builder += elem1 >> > > + builder += elem2 >> > > + builder ++= elems >> > > + ThreadContext.removeAll(builder.result.asJava) >> > > + this >> > > + } >> > > + >> > > + override def --=(xs: TraversableOnce[String]): >> > LoggingContext.this.type >> > > = { >> > > + ThreadContext.removeAll(xs.toSeq.asJava) >> > > + this >> > > + } >> > > + >> > > + override def clear(): Unit = { >> > > + ThreadContext.clearMap() >> > > + } >> > > + >> > > + override def contains(key: String): Boolean = >> > > ThreadContext.containsKey(key) >> > > + >> > > + override def get(key: String): Option[String] = >> > > Option(ThreadContext.get(key)) >> > > + >> > > + override def iterator: Iterator[(String, String)] = ThreadContext. >> > > getImmutableContext.asScala.iterator >> > > + >> > > + override def foreach[U](f: ((String, String)) => U): Unit = >> > > ThreadContext.getImmutableContext.asScala.foreach(f) >> > > + >> > > + override def size: Int = ThreadContext.getImmutableContext.size() >> > > + >> > > + override def isEmpty: Boolean = ThreadContext.isEmpty >> > > + >> > > +} >> > > >> > > http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > blob/184045cb/log4j-api-scala_2.13/src/site/markdown/index.md >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/log4j-api-scala_2.13/src/site/markdown/index.md >> > > b/log4j-api-scala_2.13/src/site/markdown/index.md >> > > new file mode 100644 >> > > index 0000000..7acf397 >> > > --- /dev/null >> > > +++ b/log4j-api-scala_2.13/src/site/markdown/index.md >> > > @@ -0,0 +1,74 @@ >> > > +<!-- >> > > + 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 2.12 API >> > > + >> > > +## Requirements >> > > + >> > > +Log4j Scala API for Scala 2.12 requires Log4j API, Java 8, the Scala >> > > runtime >> > > +library, and the Scala reflection library. To use Log4j as a logging >> > > implementation, >> > > +then Log4j Core must also be included. Instructions on using these >> > > dependencies are >> > > +in the [dependency information page][dependencies], and additional >> > > information is >> > > +included in the [Log4j artifacts][artifacts] page. >> > > + >> > > +## Example Usage >> > > + >> > > +<pre class="prettyprint linenums"> >> > > +import org.apache.logging.log4j.scala.Logging >> > > +import org.apache.logging.log4j.Level >> > > + >> > > +class MyClass extends BaseClass with Logging { >> > > + def doStuff(): Unit = { >> > > + logger.info("Doing stuff") >> > > + } >> > > + def doStuffWithLevel(level: Level): Unit = { >> > > + logger(level, "Doing stuff with arbitrary level") >> > > + } >> > > +} >> > > +</pre> >> > > + >> > > +## Configuration >> > > + >> > > +Log4j Scala 2.12 API uses the standard [Log4j >> > > configuration][configuration] >> > > +plugins. This supports XML, properties files, and a configuration >> > builder >> > > DSL by >> > > +default, and it optionally supports JSON and YAML formats with some >> > > additional >> > > +Jackson dependencies. >> > > + >> > > +## Substituting Parameters >> > > + >> > > +In the Java API, parameters to a log message are interpolated using >> > > various >> > > +strategies. In the Scala API, [string interpolation][interpolation] >> is >> > > used >> > > +instead. As all logger methods are implemented as macros, string >> > > construction and >> > > +method invocations will only occur when logging is enabled for the >> given >> > > log >> > > +level. For example: >> > > + >> > > +<pre class="prettyprint linenums"> >> > > +logger.debug(s"Logging in user ${user.getName} with birthday >> > > ${user.calcBirthday}") >> > > +</pre> >> > > + >> > > +## Logger Names >> > > + >> > > +Most logging implementations use a hierarchical scheme for matching >> > > logger names >> > > +with logging configuration. In this scheme the logger name hierarchy >> is >> > > +represented by '.' characters in the logger name, in a fashion very >> > > similar to >> > > +the hierarchy used for Java/Scala package names. The [`Logging` >> > > trait][logging] >> > > +will automatically name the Logger accordingly to the class it is >> being >> > > used in. >> > > + >> > > +[dependencies]: dependency-info.html >> > > +[artifacts]: ../maven-artifacts.html >> > > +[configuration]: ../configuration.html >> > > +[interpolation]: http://docs.scala-lang.org/overviews/core/string- >> > > interpolation.html >> > > +[logging]: scaladocs/org/apache/logging/log4j/scala/Logging.html >> > > \ No newline at end of file >> > > >> > > http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > blob/184045cb/log4j-api-scala_2.13/src/site/site.xml >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/log4j-api-scala_2.13/src/site/site.xml >> > > b/log4j-api-scala_2.13/src/site/site.xml >> > > new file mode 100644 >> > > index 0000000..f46fa51 >> > > --- /dev/null >> > > +++ b/log4j-api-scala_2.13/src/site/site.xml >> > > @@ -0,0 +1,30 @@ >> > > +<?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/184045cb/log4j-api-scala_2.13/src/test/scala/org/ >> > > apache/logging/log4j/scala/LoggerTest.scala >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/log4j-api-scala_2.13/src/test/scala/org/apache/logging/ >> > log4j/scala/LoggerTest.scala >> > > b/log4j-api-scala_2.13/src/test/scala/org/apache/logging/ >> > > log4j/scala/LoggerTest.scala >> > > new file mode 100644 >> > > index 0000000..bd12742 >> > > --- /dev/null >> > > +++ b/log4j-api-scala_2.13/src/test/scala/org/apache/logging/ >> > > log4j/scala/LoggerTest.scala >> > > @@ -0,0 +1,552 @@ >> > > +/* >> > > + * 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 >> > > + >> > > +import org.apache.logging.log4j.message.{DefaultFlowMessageFactory, >> > > Message, ParameterizedMessage, ParameterizedMessageFactory} >> > > +import org.apache.logging.log4j.spi.{AbstractLogger, ExtendedLogger} >> > > +import org.apache.logging.log4j.{Level, Marker, MarkerManager} >> > > +import org.junit.runner.RunWith >> > > +import org.mockito.Matchers.{any, anyString, eq => eqv} >> > > +import org.mockito.Mockito._ >> > > +import org.scalatest.junit.JUnitRunner >> > > +import org.scalatest.mockito.MockitoSugar >> > > +import org.scalatest.{FunSuite, Matchers} >> > > + >> > > +import scala.language.reflectiveCalls // needed for Mockito mocking >> > > + >> > > +case class Custom(i: Int) >> > > + >> > > +trait Manager { >> > > + def fetchValue(): Int >> > > +} >> > > + >> > > +@RunWith(classOf[JUnitRunner]) >> > > +class LoggerTest extends FunSuite with Matchers with MockitoSugar { >> > > + >> > > + val msg = new ParameterizedMessage("msg {}", 17) >> > > + val entryMsg = new DefaultFlowMessageFactory().ne >> wEntryMessage(msg) >> > > + val cseqMsg: CharSequence = new StringBuilder().append("cseq msg") >> > > + val objectMsg = Custom(17) >> > > + val cause = new RuntimeException("cause") >> > > + val marker = MarkerManager.getMarker("marker") >> > > + val result = "foo" >> > > + >> > > + def fixture = >> > > + new { >> > > + val mockLogger = { >> > > + val mockLogger = mock[ExtendedLogger] >> > > + when(mockLogger.getMessageFactory).thenReturn(new >> > > ParameterizedMessageFactory) >> > > + mockLogger >> > > + } >> > > + val manager = { >> > > + val mockManager = mock[Manager] >> > > + when(mockManager.fetchValue()).thenReturn(4711) >> > > + mockManager >> > > + } >> > > + } >> > > + >> > > + test("fatal enabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.FATAL)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.fatal(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.FATAL), >> > > eqv(null), any[Message], eqv(null)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("fatal disabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.FATAL)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.fatal(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + test("error enabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.ERROR)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.error(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.ERROR), >> > > eqv(null), any[Message], eqv(null)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("error disabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.ERROR)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.error(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + test("warn enabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.WARN)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.warn(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.WARN), >> > > eqv(null), any[Message], eqv(null)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("warn disabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.WARN)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.warn(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + test("info enabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.info(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(null), any[Message], eqv(null)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("info disabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.info(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + test("debug enabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.DEBUG)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.debug(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.DEBUG), >> > > eqv(null), any[Message], eqv(null)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("debug disabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.DEBUG)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.debug(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + test("trace enabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.trace(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.TRACE), >> > > eqv(null), any[Message], eqv(null)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("trace disabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.trace(s"string msg with value: ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + >> > > + test("log enabled with Message message and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, msg) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(marker), eqv(msg), eqv(null)) >> > > + } >> > > + >> > > + test("log disabled with Message message and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, msg) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with String message and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, s"string msg with value: >> > > ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(marker), any[Message], eqv(null)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("log disabled with String message and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, s"string msg with value: >> > > ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + test("log enabled with CharSequence message and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, cseqMsg) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(marker), any[Message], eqv(null)) >> > > + } >> > > + >> > > + test("log disabled with CharSequence message and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, cseqMsg) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with Object message and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, objectMsg) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(marker), any[Message], eqv(null)) >> > > + } >> > > + >> > > + test("log disabled with Object message and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, objectMsg) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with Message message and cause and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, msg, cause) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(marker), eqv(msg), eqv(cause)) >> > > + } >> > > + >> > > + test("log disabled with Message message and cause and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, msg, cause) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with String message and cause and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, s"string msg with value: >> > > ${f.manager.fetchValue()}", cause) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(marker), any[Message], eqv(cause)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("log disabled with String message and cause and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, s"string msg with value: >> > > ${f.manager.fetchValue()}", cause) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + test("log enabled with CharSequence message and cause and Marker") >> { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, cseqMsg, cause) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(marker), any[Message], eqv(cause)) >> > > + } >> > > + >> > > + test("log disabled with CharSequence message and cause and >> Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, cseqMsg, cause) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with Object message and cause and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, objectMsg, cause) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(marker), any[Message], eqv(cause)) >> > > + } >> > > + >> > > + test("log disabled with Object message and cause and Marker") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO, >> marker)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, marker, objectMsg, cause) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with Message message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, msg) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(null), eqv(msg), eqv(null)) >> > > + } >> > > + >> > > + test("log disabled with Message message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, msg) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, s"string msg with value: >> > > ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(null), any[Message], eqv(null)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("log disabled with String message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, s"string msg with value: >> > > ${f.manager.fetchValue()}") >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + test("log enabled with CharSequence message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, cseqMsg) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(null), any[Message], eqv(null)) >> > > + } >> > > + >> > > + test("log disabled with CharSequence message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, cseqMsg) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with Object message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, objectMsg) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(null), any[Message], eqv(null)) >> > > + } >> > > + >> > > + test("log disabled with Object message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, objectMsg) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with Message message and cause") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, msg, cause) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(null), eqv(msg), eqv(cause)) >> > > + } >> > > + >> > > + test("log disabled with Message message and cause") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, msg, cause) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with String message and cause") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, s"string msg with value: >> > > ${f.manager.fetchValue()}", cause) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(null), any[Message], eqv(cause)) >> > > + verify(f.manager).fetchValue() >> > > + } >> > > + >> > > + test("log disabled with String message and cause") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, s"string msg with value: >> > > ${f.manager.fetchValue()}", cause) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + verify(f.manager, never).fetchValue() >> > > + } >> > > + >> > > + test("log enabled with CharSequence message and cause") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, cseqMsg, cause) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(null), any[Message], eqv(cause)) >> > > + } >> > > + >> > > + test("log disabled with CharSequence message and cause") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, cseqMsg, cause) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + test("log enabled with Object message and cause") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, objectMsg, cause) >> > > + verify(f.mockLogger).logMessage(anyString(), eqv(Level.INFO), >> > > eqv(null), any[Message], eqv(cause)) >> > > + } >> > > + >> > > + test("log disabled with Object message and cause") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.INFO)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger(Level.INFO, objectMsg, cause) >> > > + verify(f.mockLogger, never).logMessage(anyString(), any[Level], >> > > any[Marker], any[Message], any[Throwable]) >> > > + } >> > > + >> > > + >> > > + test("traceEntry") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > > AbstractLogger.ENTRY_MARKER, null.asInstanceOf[AnyRef], >> > > null)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceEntry() >> > > + verify(f.mockLogger).traceEntry() >> > > + } >> > > + >> > > + test("traceEntry enabled with params") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > > AbstractLogger.ENTRY_MARKER, null.asInstanceOf[AnyRef], >> > > null)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceEntry("foo", "bar") >> > > + verify(f.mockLogger).traceEntry(null: String, "foo", "bar") >> > > + } >> > > + >> > > + test("traceEntry disabled with params") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > > AbstractLogger.ENTRY_MARKER, null.asInstanceOf[AnyRef], >> > > null)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceEntry("foo", "bar") >> > > + verify(f.mockLogger, never).traceEntry(anyString(), anyString(), >> > > anyString()) >> > > + } >> > > + >> > > + test("traceEntry enabled with message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > > AbstractLogger.ENTRY_MARKER, null.asInstanceOf[AnyRef], >> > > null)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceEntry(msg) >> > > + verify(f.mockLogger).traceEntry(eqv(msg)) >> > > + } >> > > + >> > > + test("traceEntry disabled with message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > > AbstractLogger.ENTRY_MARKER, null.asInstanceOf[AnyRef], >> > > null)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceEntry(msg) >> > > + verify(f.mockLogger, never).traceEntry(any[Message]) >> > > + } >> > > + >> > > + test("traceExit") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > AbstractLogger.EXIT_MARKER, >> > > msg, null)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceExit() >> > > + verify(f.mockLogger).traceExit() >> > > + } >> > > + >> > > + test("traceExit with result") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > AbstractLogger.EXIT_MARKER, >> > > msg, null)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceExit(result) >> > > + verify(f.mockLogger).traceExit(result) >> > > + } >> > > + >> > > + test("traceExit with entrymessage") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > AbstractLogger.EXIT_MARKER, >> > > msg, null)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceExit(entryMsg) >> > > + verify(f.mockLogger).traceExit(entryMsg) >> > > + } >> > > + >> > > + test("traceExit with entrymessage and result") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > AbstractLogger.EXIT_MARKER, >> > > msg, null)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceExit(entryMsg, result) >> > > + verify(f.mockLogger).traceExit(entryMsg, result) >> > > + } >> > > + >> > > + test("traceExit enabled with message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > AbstractLogger.EXIT_MARKER, >> > > msg, null)).thenReturn(true) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceExit(msg, result) >> > > + verify(f.mockLogger).traceExit(eqv(msg), eqv(result)) >> > > + } >> > > + >> > > + test("traceExit disabled with message") { >> > > + val f = fixture >> > > + when(f.mockLogger.isEnabled(Level.TRACE, >> > AbstractLogger.EXIT_MARKER, >> > > msg, null)).thenReturn(false) >> > > + val logger = Logger(f.mockLogger) >> > > + logger.traceExit(msg, result) >> > > + verify(f.mockLogger, never).traceExit(any[Message], any[AnyRef]) >> > > + } >> > > + >> > > + test("throwing") { >> > > + val f = fixture >> > > + val logger = Logger(f.mockLogger) >> > > + logger.throwing(cause) >> > > + verify(f.mockLogger).throwing(eqv(cause)) >> > > + } >> > > + >> > > + test("throwing with level") { >> > > + val f = fixture >> > > + val logger = Logger(f.mockLogger) >> > > + logger.throwing(Level.INFO, cause) >> > > + verify(f.mockLogger).throwing(eqv(Level.INFO), eqv(cause)) >> > > + } >> > > + >> > > + test("catching") { >> > > + val f = fixture >> > > + val logger = Logger(f.mockLogger) >> > > + logger.catching(cause) >> > > + verify(f.mockLogger).catching(eqv(cause)) >> > > + } >> > > + >> > > + test("catching with level") { >> > > + val f = fixture >> > > + val logger = Logger(f.mockLogger) >> > > + logger.catching(Level.INFO, cause) >> > > + verify(f.mockLogger).catching(eqv(Level.INFO), eqv(cause)) >> > > + } >> > > + >> > > +} >> > > >> > > http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > blob/184045cb/log4j-api-scala_2.13/src/test/scala/org/ >> > > apache/logging/log4j/scala/LoggingContextTest.scala >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/log4j-api-scala_2.13/src/test/scala/org/apache/logging/ >> > > log4j/scala/LoggingContextTest.scala b/log4j-api-scala_2.13/src/ >> > > test/scala/org/apache/logging/log4j/scala/LoggingContextTest.scala >> > > new file mode 100644 >> > > index 0000000..80ca940 >> > > --- /dev/null >> > > +++ b/log4j-api-scala_2.13/src/test/scala/org/apache/logging/ >> > log4j/scala/ >> > > LoggingContextTest.scala >> > > @@ -0,0 +1,115 @@ >> > > +/* >> > > + * 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 >> > > + >> > > +import org.junit.runner.RunWith >> > > +import org.scalatest.junit.JUnitRunner >> > > +import org.scalatest.{FunSuite, Matchers} >> > > + >> > > +import scala.collection.mutable >> > > + >> > > +@RunWith(classOf[JUnitRunner]) >> > > +class LoggingContextTest extends FunSuite with Matchers { >> > > + >> > > + test("put single, contains, get") { >> > > + LoggingContext += "key" -> "value" >> > > + >> > > + LoggingContext.contains("key") shouldBe true >> > > + LoggingContext.get("key") shouldBe Some("value") >> > > + LoggingContext.contains("bogus") shouldBe false >> > > + LoggingContext.get("bogus") shouldBe None >> > > + } >> > > + >> > > + test("put multiple 1") { >> > > + LoggingContext += ("key1" -> "value1", "key2" -> "value2") >> > > + >> > > + LoggingContext.get("key1") shouldBe Some("value1") >> > > + LoggingContext.get("key2") shouldBe Some("value2") >> > > + } >> > > + >> > > + test("put multiple 2") { >> > > + LoggingContext ++= Seq("key1" -> "value1", "key2" -> "value2") >> > > + >> > > + LoggingContext.get("key1") shouldBe Some("value1") >> > > + LoggingContext.get("key2") shouldBe Some("value2") >> > > + } >> > > + >> > > + test("remove single") { >> > > + LoggingContext += ("key1" -> "value1") >> > > + LoggingContext += ("key2" -> "value2") >> > > + LoggingContext += ("key3" -> "value3") >> > > + >> > > + LoggingContext -= "key1" >> > > + >> > > + LoggingContext.get("key1") shouldBe None >> > > + LoggingContext.get("key2") shouldBe Some("value2") >> > > + LoggingContext.get("key3") shouldBe Some("value3") >> > > + } >> > > + >> > > + test("remove multiple 1") { >> > > + LoggingContext += ("key1" -> "value1") >> > > + LoggingContext += ("key2" -> "value2") >> > > + LoggingContext += ("key3" -> "value3") >> > > + >> > > + LoggingContext -= ("key1", "key2") >> > > + >> > > + LoggingContext.get("key1") shouldBe None >> > > + LoggingContext.get("key2") shouldBe None >> > > + LoggingContext.get("key3") shouldBe Some("value3") >> > > + } >> > > + >> > > + test("remove multiple 2") { >> > > + LoggingContext += ("key1" -> "value1") >> > > + LoggingContext += ("key2" -> "value2") >> > > + LoggingContext += ("key3" -> "value3") >> > > + >> > > + LoggingContext --= Seq("key1", "key2") >> > > + >> > > + LoggingContext.get("key1") shouldBe None >> > > + LoggingContext.get("key2") shouldBe None >> > > + LoggingContext.get("key3") shouldBe Some("value3") >> > > + } >> > > + >> > > + test("clear, size, isEmpty") { >> > > + LoggingContext += ("key" -> "value") >> > > + >> > > + LoggingContext.clear() >> > > + >> > > + LoggingContext.contains("key") shouldBe false >> > > + LoggingContext.size shouldBe 0 >> > > + LoggingContext.isEmpty shouldBe true >> > > + } >> > > + >> > > + test("iterator") { >> > > + LoggingContext += ("key1" -> "value1") >> > > + LoggingContext += ("key2" -> "value2") >> > > + >> > > + LoggingContext.iterator.toSet shouldBe Set("key1" -> "value1", >> > "key2" >> > > -> "value2") >> > > + } >> > > + >> > > + test("foreach") { >> > > + LoggingContext += ("key1" -> "value1") >> > > + LoggingContext += ("key2" -> "value2") >> > > + >> > > + val result = mutable.Set.empty[(String, String)] >> > > + >> > > + LoggingContext.foreach { result += _ } >> > > + >> > > + result shouldBe Set("key1" -> "value1", "key2" -> "value2") >> > > + } >> > > + >> > > +} >> > > >> > > http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/ >> > > blob/184045cb/pom.xml >> > > ------------------------------------------------------------ >> ---------- >> > > diff --git a/pom.xml b/pom.xml >> > > index 1068ecb..c26cc7a 100644 >> > > --- a/pom.xml >> > > +++ b/pom.xml >> > > @@ -106,6 +106,7 @@ >> > > <module>log4j-api-scala_2.10</module> >> > > <module>log4j-api-scala_2.11</module> >> > > <module>log4j-api-scala_2.12</module> >> > > +<!--<module>log4j-api-scala_2.13</module> --> >> > > <module>log4j-api-scala-sample</module> >> > > </modules> >> > > >> > > >> > > >> > >> > >> > -- >> > Matt Sicker <boa...@gmail.com> >> > >> > > > > -- > Matt Sicker <boa...@gmail.com> > -- Matt Sicker <boa...@gmail.com>