Skip to content

Commit

Permalink
add example confliction (scala-logging)
Browse files Browse the repository at this point in the history
  • Loading branch information
OutOfBedlam committed May 27, 2019
1 parent a2eb3ec commit bf49b4e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ lazy val root = (project in file("."))
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % "2.12.8" % Provided,
"org.slf4j" % "slf4j-api" % "1.7.26" % Provided,
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.2" % Provided,
"org.scalatest" %% "scalatest" % "3.0.5" % Test,
"ch.qos.logback" % "logback-classic" % "1.2.3" % Test,
)
Expand Down
22 changes: 19 additions & 3 deletions src/test/scala/com/thing2x/smqd/logging/MacroTest.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.thing2x.smqd.logging
import com.thing2x.smqd.logging.MacroTest.Demo
import com.typesafe.scalalogging.StrictLogging
import org.scalatest.FlatSpec

object Position extends SourcePositionAware {
Expand All @@ -13,7 +14,7 @@ object MacroTest {

class Demo extends AbstractDemo {
def doDemo(): Unit = {
logger.info(s"| $FILE $LINE | Demo logging")
logger.info(s"($FILE $LINE) Demo logging")
}
}
}
Expand All @@ -23,9 +24,9 @@ class MacroTest extends FlatSpec with SourcePositionLogging {
"Macro" should "work" in {

val str = Position.str
assert(str == "MacroTest.scala 6")
assert(str.matches("MacroTest.scala\\s[0-9]+$"))

println(s"==> $str")
logger.info(s"Position.str ==> $str")

var n = 0
logger.trace(s"some trace message ${n = n + 1; n}")
Expand All @@ -41,4 +42,19 @@ class MacroTest extends FlatSpec with SourcePositionLogging {
demo.doDemo()
logger.info("finish demo")
}

it should "work with duplicated logger" in {
val demo = new DemoClass
demo.invokeMe()
}
}

abstract class DemoImpl extends StrictLogging {
def invokeMe(): Unit
}

class DemoClass extends DemoImpl with SourcePositionAware {
def invokeMe(): Unit = {
logger.info(s"| $FILE $LINE | How to solve confliction with scala-logging issue")
}
}

0 comments on commit bf49b4e

Please sign in to comment.