diff --git a/core/shared/src/main/scala/org/typelevel/log4cats/extras/LogMessage.scala b/core/shared/src/main/scala/org/typelevel/log4cats/extras/LogMessage.scala index dc3c2449..d9782202 100644 --- a/core/shared/src/main/scala/org/typelevel/log4cats/extras/LogMessage.scala +++ b/core/shared/src/main/scala/org/typelevel/log4cats/extras/LogMessage.scala @@ -82,12 +82,18 @@ object LogMessage { def t: Option[Throwable] = error - def copy( - l: LogLevel = level, - tOpt: Option[Throwable] = error, - msg: String = message - ): LogMessage = + def copy(l: LogLevel, tOpt: Option[Throwable], msg: String): LogMessage = LogMessageImpl(l, tOpt, () => msg, context) + + // Had to add this explicitly because of issues with overloading and default arguments + @nowarn("msg=unused") + private def copy( + ll: LogLevel, + e: Option[Throwable], + lm: () => String, + c: Map[String, String] + ): LogMessage = + LogMessageImpl(ll, e, lm, c) } implicit val logMessageShow: Show[LogMessage] = diff --git a/testing/shared/src/main/scala/org/typelevel/log4cats/testing/StructuredTestingLogger.scala b/testing/shared/src/main/scala/org/typelevel/log4cats/testing/StructuredTestingLogger.scala index 29d7f978..bfbc2f89 100644 --- a/testing/shared/src/main/scala/org/typelevel/log4cats/testing/StructuredTestingLogger.scala +++ b/testing/shared/src/main/scala/org/typelevel/log4cats/testing/StructuredTestingLogger.scala @@ -115,8 +115,6 @@ object StructuredTestingLogger { } mod() } - def retrieveLogMessages: F[Vector[LogMessage]] = Sync[F].delay(ar.get()) - make[F]( traceEnabled = traceEnabled, debugEnabled = debugEnabled, @@ -124,7 +122,7 @@ object StructuredTestingLogger { warnEnabled = warnEnabled, errorEnabled = errorEnabled, appendLogMessage = appendLogMessage, - read = retrieveLogMessages _ + read = () => Sync[F].delay(ar.get()) ) } diff --git a/testing/shared/src/main/scala/org/typelevel/log4cats/testing/TestingLogger.scala b/testing/shared/src/main/scala/org/typelevel/log4cats/testing/TestingLogger.scala index 7b4265bf..a20650aa 100644 --- a/testing/shared/src/main/scala/org/typelevel/log4cats/testing/TestingLogger.scala +++ b/testing/shared/src/main/scala/org/typelevel/log4cats/testing/TestingLogger.scala @@ -94,7 +94,6 @@ object TestingLogger { } mod() } - def retrieveLogMessages: F[Vector[LogMessage]] = Sync[F].delay(ar.get()) make[F]( traceEnabled = traceEnabled, @@ -103,7 +102,7 @@ object TestingLogger { warnEnabled = warnEnabled, errorEnabled = errorEnabled, appendLogMessage = appendLogMessage, - read = retrieveLogMessages _ + read = () => Sync[F].delay(ar.get()) ) } diff --git a/testing/shared/src/main/scala/org/typelevel/log4cats/testing/TestingLoggerFactory.scala b/testing/shared/src/main/scala/org/typelevel/log4cats/testing/TestingLoggerFactory.scala index e3bad396..c05c95e9 100644 --- a/testing/shared/src/main/scala/org/typelevel/log4cats/testing/TestingLoggerFactory.scala +++ b/testing/shared/src/main/scala/org/typelevel/log4cats/testing/TestingLoggerFactory.scala @@ -103,7 +103,7 @@ object TestingLoggerFactory { if (log.ctx.nonEmpty) { builder.append('\n') } - log.ctx.foreach { case k -> v => + log.ctx.foreach { case (k, v) => builder.append(" ").append(k).append(':').append(v).append('\n') } builder.result() @@ -146,7 +146,6 @@ object TestingLoggerFactory { } mod() } - def retrieveLogMessages: F[Vector[LogMessage]] = Sync[F].delay(ar.get()) make[F]( traceEnabled = traceEnabled, @@ -155,7 +154,7 @@ object TestingLoggerFactory { warnEnabled = warnEnabled, errorEnabled = errorEnabled, save = appendLogMessage, - read = retrieveLogMessages _ + read = () => Sync[F].delay(ar.get()) ) }