From 5951089d70aeb6cb2cd3ec8832b3a0860ff7c5f8 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 22 Feb 2022 22:15:29 +0100 Subject: [PATCH 1/2] Update scribe, scribe-slf4j to 3.8.0 --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 28bf6aeb..2a5035e5 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -42,7 +42,7 @@ object Dependencies { val PureConfigVersion = "0.17.1" val ScalaJavaTimeVersion = "2.3.0" val ScodecBitsVersion = "1.1.30" - val ScribeVersion = "3.7.1" + val ScribeVersion = "3.8.0" val Slf4jVersion = "1.7.36" val SourcecodeVersion = "0.2.8" val StanfordNlpVersion = "4.4.0" From 0c56549736adb575d5df37e11c849194eabcd425 Mon Sep 17 00:00:00 2001 From: eikek Date: Tue, 22 Feb 2022 22:40:00 +0100 Subject: [PATCH 2/2] Adopt to new scribe version --- .../logging/impl/ScribeConfigure.scala | 9 +-- .../docspell/logging/impl/StdoutWriter.scala | 56 ------------------- 2 files changed, 5 insertions(+), 60 deletions(-) delete mode 100644 modules/logging/scribe/src/main/scala/docspell/logging/impl/StdoutWriter.scala diff --git a/modules/logging/scribe/src/main/scala/docspell/logging/impl/ScribeConfigure.scala b/modules/logging/scribe/src/main/scala/docspell/logging/impl/ScribeConfigure.scala index 1b8b6c79..d0324ef5 100644 --- a/modules/logging/scribe/src/main/scala/docspell/logging/impl/ScribeConfigure.scala +++ b/modules/logging/scribe/src/main/scala/docspell/logging/impl/ScribeConfigure.scala @@ -13,6 +13,7 @@ import docspell.logging.{Level, LogConfig} import scribe.format.Formatter import scribe.jul.JULHandler +import scribe.writer.SystemOutWriter object ScribeConfigure { private[this] val docspellRootVerbose = "DOCSPELL_ROOT_LOGGER_LEVEL" @@ -45,13 +46,13 @@ object ScribeConfigure { l => cfg.format match { case Format.Fancy => - l.withHandler(formatter = Formatter.enhanced, writer = StdoutWriter) + l.withHandler(formatter = Formatter.enhanced, writer = SystemOutWriter) case Format.Plain => - l.withHandler(formatter = Formatter.classic, writer = StdoutWriter) + l.withHandler(formatter = Formatter.classic, writer = SystemOutWriter) case Format.Json => - l.withHandler(writer = JsonWriter(StdoutWriter)) + l.withHandler(writer = JsonWriter(SystemOutWriter)) case Format.Logfmt => - l.withHandler(writer = LogfmtWriter(StdoutWriter)) + l.withHandler(writer = LogfmtWriter(SystemOutWriter)) }, _.replace() ) diff --git a/modules/logging/scribe/src/main/scala/docspell/logging/impl/StdoutWriter.scala b/modules/logging/scribe/src/main/scala/docspell/logging/impl/StdoutWriter.scala deleted file mode 100644 index ba79d892..00000000 --- a/modules/logging/scribe/src/main/scala/docspell/logging/impl/StdoutWriter.scala +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020 Eike K. & Contributors - * - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -package docspell.logging.impl - -import scribe._ -import scribe.output.LogOutput -import scribe.output.format.OutputFormat -import scribe.writer.Writer - -// From: https://github.com/outr/scribe/blob/8e99521e1ee1f0c421629764dd96e4eb193d84bd/core/shared/src/main/scala/scribe/writer/SystemOutputWriter.scala -// Modified to always log to stdout. The original code was logging to stdout and stderr -// depending on the log level. -// Original code licensed under MIT - -private[impl] object StdoutWriter extends Writer { - - /** If true, will always synchronize writing to the console to avoid interleaved text. - * Most native consoles will handle this automatically, but IntelliJ and Eclipse are - * notorious about not properly handling this. Defaults to true. - */ - val synchronizeWriting: Boolean = true - - /** Workaround for some consoles that don't play nicely with asynchronous calls */ - val alwaysFlush: Boolean = false - - private val stringBuilders = new ThreadLocal[StringBuilder] { - override def initialValue(): StringBuilder = new StringBuilder(512) - } - - @annotation.nowarn - override def write[M]( - record: LogRecord[M], - output: LogOutput, - outputFormat: OutputFormat - ): Unit = { - val stream = Logger.system.out - val sb = stringBuilders.get() - outputFormat.begin(sb.append(_)) - outputFormat(output, s => sb.append(s)) - outputFormat.end(sb.append(_)) - if (synchronizeWriting) { - synchronized { - stream.println(sb.toString()) - if (alwaysFlush) stream.flush() - } - } else { - stream.println(sb.toString()) - if (alwaysFlush) stream.flush() - } - sb.clear() - } -}