Skip to content
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
68 changes: 37 additions & 31 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,8 @@ val scalaTestPlusScalaCheck = {
Def.setting("org.scalatestplus" %%% s"scalacheck-$scalaCheckSuffix" % Versions.scalaTestPlusScalaCheck)
}

lazy val loggerDependencies = Seq(
"ch.qos.logback" % "logback-classic" % "1.4.14",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5"
)
lazy val logback = "ch.qos.logback" % "logback-classic" % Versions.logback
lazy val slf4j = "org.slf4j" % "slf4j-api" % Versions.slf4j

lazy val rawAllAggregates = core.projectRefs ++
testing.projectRefs ++
Expand Down Expand Up @@ -372,10 +370,11 @@ lazy val clientTestServer = (projectMatrix in file("client/testserver"))
.settings(
name := "testing-server",
publish / skip := true,
libraryDependencies ++= loggerDependencies ++ Seq(
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-dsl" % Versions.http4s,
"org.http4s" %% "http4s-blaze-server" % Versions.http4sBlazeServer,
"org.http4s" %% "http4s-circe" % Versions.http4s
"org.http4s" %% "http4s-circe" % Versions.http4s,
logback
),
// the test server needs to be started before running any client tests
reStart / mainClass := Some("sttp.tapir.client.tests.HttpServer"),
Expand Down Expand Up @@ -467,7 +466,10 @@ lazy val testing: ProjectMatrix = (projectMatrix in file("testing"))
.settings(commonSettings)
.settings(
name := "tapir-testing",
libraryDependencies ++= Seq(scalaTest.value % Test) ++ loggerDependencies
libraryDependencies ++= Seq(
scalaTest.value % Test,
logback % Test
)
)
.jvmPlatform(scalaVersions = scala2And3Versions)
.jsPlatform(scalaVersions = scala2And3Versions, settings = commonJsSettings)
Expand All @@ -482,8 +484,9 @@ lazy val tests: ProjectMatrix = (projectMatrix in file("tests"))
"io.circe" %%% "circe-generic" % Versions.circe,
"com.softwaremill.common" %%% "tagging" % "2.3.4",
scalaTest.value,
"org.typelevel" %%% "cats-effect" % Versions.catsEffect
) ++ loggerDependencies
"org.typelevel" %%% "cats-effect" % Versions.catsEffect,
logback
)
)
.jvmPlatform(scalaVersions = scala2And3Versions)
.jsPlatform(
Expand Down Expand Up @@ -515,8 +518,9 @@ lazy val perfTests: ProjectMatrix = (projectMatrix in file("perf-tests"))
"org.http4s" %% "http4s-core" % Versions.http4s,
"org.http4s" %% "http4s-dsl" % Versions.http4s,
"org.http4s" %% "http4s-blaze-server" % Versions.http4sBlazeServer,
"org.typelevel" %%% "cats-effect" % Versions.catsEffect
) ++ loggerDependencies,
"org.typelevel" %%% "cats-effect" % Versions.catsEffect,
logback
),
publishArtifact := false
)
.settings(Gatling / scalaSource := sourceDirectory.value / "test" / "scala")
Expand Down Expand Up @@ -933,10 +937,12 @@ lazy val protobuf: ProjectMatrix = (projectMatrix in file("grpc/protobuf"))
.settings(commonSettings)
.settings(
name := "tapir-grpc-protobuf",
libraryDependencies ++= loggerDependencies ++ Seq(
libraryDependencies ++= Seq(
slf4j,
scalaTest.value % Test,
scalaCheck.value % Test,
scalaTestPlusScalaCheck.value % Test
scalaTestPlusScalaCheck.value % Test,
logback % Test
)
)
.jvmPlatform(scalaVersions = scala2Versions)
Expand All @@ -961,7 +967,8 @@ lazy val grpcExamples: ProjectMatrix = (projectMatrix in file("grpc/examples"))
.settings(
name := "tapir-grpc-examples",
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-discovery" % "2.6.20"
"com.typesafe.akka" %% "akka-discovery" % "2.6.20",
slf4j
),
fork := true
)
Expand All @@ -978,7 +985,8 @@ lazy val pekkoGrpcExamples: ProjectMatrix = (projectMatrix in file("grpc/pekko-e
.settings(
name := "tapir-pekko-grpc-examples",
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-discovery" % "1.0.2"
"org.apache.pekko" %% "pekko-discovery" % "1.0.2",
slf4j
),
fork := true
)
Expand Down Expand Up @@ -1398,7 +1406,7 @@ lazy val jdkhttpServer: ProjectMatrix = (projectMatrix in file("server/jdkhttp-s
name := "tapir-jdkhttp-server",
libraryDependencies ++= Seq(
"org.apache.httpcomponents" % "httpmime" % "4.5.14"
) ++ loggerDependencies
)
)
.jvmPlatform(scalaVersions = List(scala2_13, scala3))
.dependsOn(serverCore, serverTests % Test)
Expand All @@ -1409,17 +1417,17 @@ lazy val nettyServer: ProjectMatrix = (projectMatrix in file("server/netty-serve
name := "tapir-netty-server",
libraryDependencies ++= Seq(
"io.netty" % "netty-all" % Versions.nettyAll,
"org.playframework.netty" % "netty-reactive-streams-http" % Versions.nettyReactiveStreams
)
++ loggerDependencies,
"org.playframework.netty" % "netty-reactive-streams-http" % Versions.nettyReactiveStreams,
slf4j
),
// needed because of https://github.com/coursier/coursier/issues/2016
useCoursier := false
)
.jvmPlatform(scalaVersions = scala2And3Versions)
.dependsOn(serverCore, serverTests % Test)

lazy val nettyServerLoom: ProjectMatrix =
ProjectMatrix("nettyServerLoom", file(s"server/netty-server/loom"))
ProjectMatrix("nettyServerLoom", file("server/netty-server/loom"))
.settings(commonJvmSettings)
.settings(
name := "tapir-netty-server-loom",
Expand All @@ -1433,7 +1441,8 @@ lazy val nettyServerCats: ProjectMatrix = nettyServerProject("cats", catsEffect)
.settings(
libraryDependencies ++= Seq(
"com.softwaremill.sttp.shared" %% "fs2" % Versions.sttpShared,
"co.fs2" %% "fs2-reactive-streams" % Versions.fs2
"co.fs2" %% "fs2-reactive-streams" % Versions.fs2,
slf4j
)
)

Expand All @@ -1450,7 +1459,6 @@ def nettyServerProject(proj: String, dependency: ProjectMatrix): ProjectMatrix =
.settings(commonJvmSettings)
.settings(
name := s"tapir-netty-server-$proj",
libraryDependencies ++= loggerDependencies,
// needed because of https://github.com/coursier/coursier/issues/2016
useCoursier := false
)
Expand All @@ -1464,7 +1472,7 @@ lazy val nimaServer: ProjectMatrix = (projectMatrix in file("server/nima-server"
libraryDependencies ++= Seq(
"io.helidon.webserver" % "helidon-webserver" % Versions.helidon,
"io.helidon.logging" % "helidon-logging-slf4j" % Versions.helidon
) ++ loggerDependencies
)
)
.jvmPlatform(scalaVersions = scala2_13And3Versions)
.dependsOn(serverCore, serverTests % Test)
Expand Down Expand Up @@ -1518,7 +1526,6 @@ lazy val awsLambdaCore: ProjectMatrix = (projectMatrix in file("serverless/aws/l
.settings(commonJvmSettings)
.settings(
name := "tapir-aws-lambda-core",
libraryDependencies ++= loggerDependencies
)
.jvmPlatform(scalaVersions = scala2And3Versions)
.jsPlatform(scalaVersions = scala2Versions)
Expand All @@ -1528,7 +1535,6 @@ lazy val awsLambdaZio: ProjectMatrix = (projectMatrix in file("serverless/aws/la
.settings(commonJvmSettings)
.settings(
name := "tapir-aws-lambda-zio",
libraryDependencies ++= loggerDependencies,
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-lambda-java-runtime-interface-client" % Versions.awsLambdaInterface
)
Expand Down Expand Up @@ -1599,10 +1605,10 @@ lazy val awsLambdaCatsEffect: ProjectMatrix = (projectMatrix in file("serverless
.settings(commonJvmSettings)
.settings(
name := "tapir-aws-lambda",
libraryDependencies ++= loggerDependencies,
libraryDependencies ++= Seq(
"com.softwaremill.sttp.client3" %% "fs2" % Versions.sttp,
"com.amazonaws" % "aws-lambda-java-runtime-interface-client" % Versions.awsLambdaInterface
"com.amazonaws" % "aws-lambda-java-runtime-interface-client" % Versions.awsLambdaInterface,
slf4j
)
)
.jvmPlatform(scalaVersions = scala2And3Versions)
Expand Down Expand Up @@ -2019,9 +2025,9 @@ lazy val examples2: ProjectMatrix = (projectMatrix in file("examples2"))
"io.opentelemetry" % "opentelemetry-sdk" % Versions.openTelemetry,
"io.opentelemetry" % "opentelemetry-sdk-metrics" % Versions.openTelemetry,
"io.opentelemetry" % "opentelemetry-exporter-otlp" % Versions.openTelemetry,
scalaTest.value
scalaTest.value,
logback
),
libraryDependencies ++= loggerDependencies,
publishArtifact := false,
Compile / run / fork := true
)
Expand Down Expand Up @@ -2077,9 +2083,9 @@ lazy val examples: ProjectMatrix = (projectMatrix in file("examples"))
"io.opentelemetry" % "opentelemetry-sdk" % Versions.openTelemetry,
"io.opentelemetry" % "opentelemetry-sdk-metrics" % Versions.openTelemetry,
"io.opentelemetry" % "opentelemetry-exporter-otlp" % Versions.openTelemetry,
scalaTest.value
scalaTest.value,
logback
),
libraryDependencies ++= loggerDependencies,
publishArtifact := false
)
.jvmPlatform(scalaVersions = examplesScalaVersions)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package sttp.tapir.examples

import com.typesafe.scalalogging.StrictLogging
import sttp.tapir.examples.logging.Logging
import sttp.tapir.generic.auto.*

object BooksExample extends App with StrictLogging {
object BooksExample extends App with Logging {
type Limit = Option[Int]
type AuthToken = String

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package sttp.tapir.examples

import com.typesafe.scalalogging.StrictLogging
import sttp.tapir.examples.logging.Logging
import sttp.tapir.server.netty.{NettyFutureServer, NettyFutureServerBinding}

import scala.concurrent.Await
import scala.concurrent.duration.Duration

object BooksPicklerExample extends App with StrictLogging {
object BooksPicklerExample extends App with Logging {
type Limit = Option[Int]
type AuthToken = String

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package sttp.tapir.examples.client

import cats.effect.{ExitCode, IO, IOApp}
import com.typesafe.scalalogging.StrictLogging
import sttp.tapir.examples.logging.Logging
import io.circe.generic.auto.*
import sttp.tapir.*
import sttp.tapir.client.http4s.Http4sClientInterpreter
import sttp.tapir.generic.auto.*
import sttp.tapir.json.circe.*

object Http4sClientExample extends IOApp with StrictLogging {
object Http4sClientExample extends IOApp with Logging {

case class User(id: Int, name: String)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package sttp.tapir.examples.custom_types

import com.typesafe.scalalogging.StrictLogging
import sttp.tapir.examples.logging.Logging
import sttp.tapir.Schema

object BooksExampleSemiauto extends App with StrictLogging {
object BooksExampleSemiauto extends App with Logging {
type Limit = Option[Int]
type AuthToken = String

Expand Down
15 changes: 15 additions & 0 deletions examples/src/main/scala/sttp/tapir/examples/logging/Logging.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package sttp.tapir.examples.logging

import org.slf4j.{Logger, LoggerFactory}

/**
* Defines a [[org.slf4j.Logger]] instance `logger` named according to the class
* into which this trait is mixed.
*
* In a real-life project, you might rather want to use a macros-based SLF4J wrapper
* or logging backend.
*/
trait Logging {

protected val logger: Logger = LoggerFactory.getLogger(getClass.getName)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sttp.tapir.examples.observability

import com.timgroup.statsd.NonBlockingStatsDClientBuilder
import com.typesafe.scalalogging.StrictLogging
import sttp.tapir.examples.logging.Logging
import io.circe.generic.auto.*
import sttp.tapir.*
import sttp.tapir.generic.auto.*
Expand All @@ -15,7 +15,7 @@ import scala.concurrent.duration.*
import scala.concurrent.{Await, Future}
import scala.io.StdIn

object DatadogMetricsExample extends App with StrictLogging {
object DatadogMetricsExample extends App with Logging {

case class Person(name: String)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sttp.tapir.examples.observability

import com.typesafe.scalalogging.StrictLogging
import sttp.tapir.examples.logging.Logging
import io.circe.generic.auto.*
import io.opentelemetry.api.OpenTelemetry
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter
Expand Down Expand Up @@ -57,7 +57,7 @@ import scala.io.StdIn
* ...
* }}}
*/
object OpenTelemetryMetricsExample extends App with StrictLogging {
object OpenTelemetryMetricsExample extends App with Logging {

case class Person(name: String)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sttp.tapir.examples.observability

import com.typesafe.scalalogging.StrictLogging
import sttp.tapir.examples.logging.Logging
import io.circe.generic.auto.*
import sttp.tapir.*
import sttp.tapir.generic.auto.*
Expand All @@ -14,7 +14,7 @@ import scala.concurrent.duration.*
import scala.concurrent.{Await, Future}
import scala.io.StdIn

object PrometheusMetricsExample extends App with StrictLogging {
object PrometheusMetricsExample extends App with Logging {

case class Person(name: String)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sttp.tapir.examples.streaming

import cats.effect.{ExitCode, IO, IOApp}
import com.typesafe.scalalogging.StrictLogging
import sttp.tapir.examples.logging.Logging
import fs2.Stream
import org.http4s.HttpRoutes
import org.http4s.blaze.server.BlazeServerBuilder
Expand All @@ -14,7 +14,7 @@ import sttp.tapir.*
import sttp.tapir.server.http4s.Http4sServerInterpreter

/** Proxies requests from /proxy to https://httpbin.org/anything */
object ProxyHttp4sFs2Server extends IOApp with StrictLogging {
object ProxyHttp4sFs2Server extends IOApp with Logging {
val proxyEndpoint: PublicEndpoint[
(Method, List[String], QueryParams, List[Header], Stream[IO, Byte]),
Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import akka.grpc.GrpcClientSettings
import akka.http.scaladsl.Http
import cats.implicits._
import com.typesafe.config.ConfigFactory
import com.typesafe.scalalogging.StrictLogging
import org.slf4j.{Logger, LoggerFactory}
import sttp.tapir._
import sttp.tapir.grpc.protobuf._
import sttp.tapir.grpc.protobuf.pbdirect._
Expand All @@ -21,6 +21,9 @@ import sttp.tapir.grpc.examples.grpc_simple_books_example.gen.{
import java.util.concurrent.atomic.AtomicLong
import scala.concurrent.{Await, ExecutionContext, Future}

trait Logging {
protected val logger: Logger = LoggerFactory.getLogger(getClass.getName)
}
case class SimpleBook(id: Long, title: String, description: String)
case class AddBookMsg(title: String, description: String)

Expand All @@ -35,7 +38,7 @@ object Endpoints {
val endpoints = List(addBook)
}

object SimpleBooksExampleServer extends StrictLogging {
object SimpleBooksExampleServer extends Logging {

import Endpoints._

Expand All @@ -59,7 +62,7 @@ object SimpleBooksExampleServer extends StrictLogging {
}
}

class ExampleGrpcServer(system: ActorSystem) extends StrictLogging {
class ExampleGrpcServer(system: ActorSystem) extends Logging {
def run(): Future[Http.ServerBinding] = {
// Akka boot up code
implicit val sys: ActorSystem = system
Expand All @@ -84,7 +87,7 @@ object SimpleBookExampleProtoGenerator extends App {
)
}

object SimpleBookExampleClient extends App with StrictLogging {
object SimpleBookExampleClient extends App with Logging {

import scala.concurrent.duration._

Expand Down
Loading