Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Xsource:3 #214

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ch.qos.logback.classic.spi.{ILoggingEvent, IThrowableProxy, ThrowableProx
import com.google.cloud.logging.HttpRequest.RequestMethod
import com.google.cloud.logging.Logging.WriteOption
import com.google.cloud.logging.logback.LoggingAppender
import com.google.cloud.logging.{Option => _, _}
import com.google.cloud.logging.{Option as _, *}
import io.circe.{Json, JsonNumber, JsonObject}
import io.github.nafg.cloudlogging.marker.JsonMarker
import org.slf4j.Marker
Expand All @@ -16,7 +16,7 @@ import java.time.Instant
import java.util
import java.util.Collections
import scala.collection.mutable
import scala.jdk.CollectionConverters._
import scala.jdk.CollectionConverters.*

object CloudJsonLoggingAppender {
private def severityFor(level: Level) =
Expand Down Expand Up @@ -215,6 +215,6 @@ class CloudJsonLoggingAppender extends LoggingAppender {

override def append(e: ILoggingEvent): Unit = {
val logEntry = CloudJsonLoggingAppender.logEntryFor(e)
logging.write(Collections.singleton(logEntry), defaultWriteOptions: _*)
logging.write(Collections.singleton(logEntry), defaultWriteOptions*)
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package io.github.nafg.cloudlogging.appender

import java.util

import scala.jdk.CollectionConverters._

import io.github.nafg.cloudlogging.marker.JsonMarker

import ch.qos.logback.classic.spi._
import ch.qos.logback.classic.spi.*
import ch.qos.logback.classic.{Level, LoggerContext}
import com.google.cloud.logging.{Payload, Severity}
import io.circe.Json
import org.scalatest.Inside._
import io.github.nafg.cloudlogging.marker.JsonMarker
import org.scalatest.Inside.*
import org.scalatest.funsuite.AnyFunSuite
import org.slf4j.Marker

import java.util
import scala.jdk.CollectionConverters.*

class CloudJsonLoggingAppenderTests extends AnyFunSuite {
test("Exception") {
val loggingEvent: ILoggingEvent = new ILoggingEvent {
Expand Down Expand Up @@ -49,11 +47,11 @@ class CloudJsonLoggingAppenderTests extends AnyFunSuite {
assert(message.startsWith(loggingEvent.getMessage))
}

inside(data.get("marker")) { case marker: util.Map[_, _] =>
inside(data.get("marker")) { case marker: util.Map[String, String] =>
assert(marker.get("name") == "testMarker")
}

inside(data.get("throwable")) { case throwable: util.Map[_, _] =>
inside(data.get("throwable")) { case throwable: util.Map[String, String] =>
assert(throwable.get("message") == "Some error")
assert(throwable.containsKey("stack"))
}
Expand Down
13 changes: 10 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ mergifyExtraConditions := Seq(
(Attr.Author :== "nafg-scala-steward[bot]")
)

val noFatalWarnings = scalacOptions -= "-Xfatal-warnings"
val adjustScalacOptions = Seq(
scalacOptions -= "-Xfatal-warnings",
scalacOptions ++=
(if (scalaVersion.value.startsWith("3."))
Nil
else
Seq("-Xsource:3"))
)

lazy val marker =
project
.settings(
noFatalWarnings,
adjustScalacOptions,
libraryDependencies += "io.circe" %% "circe-core" % "0.14.5",
libraryDependencies += "org.slf4j" % "slf4j-api" % "2.0.7"
)
Expand All @@ -24,7 +31,7 @@ lazy val appender =
project
.dependsOn(marker)
.settings(
noFatalWarnings,
adjustScalacOptions,
libraryDependencies += "com.google.cloud" % "google-cloud-logging-logback" % "0.130.21-alpha",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.16" % Test
)
Expand Down