diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53ebc04b..51f9bcaa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,16 +9,17 @@ name: Continuous Integration on: pull_request: - branches: ['*', series/*] + branches: ['**'] push: - branches: ['*', series/*] - tags: [v*, v*] + branches: ['**'] + tags: [v*] env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} PGP_SECRET: ${{ secrets.PGP_SECRET }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: build: @@ -28,6 +29,14 @@ jobs: os: [ubuntu-latest] scala: [2.13.8, 2.12.15, 3.0.2] java: [temurin@8, temurin@11] + project: [rootJS, rootJVM] + exclude: + - scala: 2.13.8 + java: temurin@11 + - scala: 2.12.15 + java: temurin@11 + - project: rootJS + java: temurin@11 runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -62,27 +71,46 @@ jobs: key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: Check that workflows are up to date - run: sbt ++${{ matrix.scala }} githubWorkflowCheck + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'project /' githubWorkflowCheck + + - name: Check headers and formatting + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck + + - name: fastOptJS + if: matrix.project == 'rootJS' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/fastOptJS - name: Test - run: sbt ++${{ matrix.scala }} test + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test - - name: Binary Compatibility Check - run: sbt ++${{ matrix.scala }} mimaReportBinaryIssues + - name: Check binary compatibility + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues + + - name: Generate API documentation + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc + + - name: Make target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: mkdir -p testing/jvm/target noop/jvm/target target .js/target site/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/target project/target - name: Compress target directories - run: tar cf targets.tar testing/jvm/target noop/jvm/target docs/target target core/js/target testing/js/target noop/js/target core/jvm/target slf4j/target project/target + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: tar cf targets.tar testing/jvm/target noop/jvm/target target .js/target site/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/target project/target - name: Upload target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') uses: actions/upload-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }} + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} path: targets.tar publish: name: Publish Artifacts needs: [build] - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') strategy: matrix: os: [ubuntu-latest] @@ -121,151 +149,87 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Download target directories (2.13.8) + - name: Download target directories (2.13.8, rootJS) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-2.13.8-${{ matrix.java }} + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJS - - name: Inflate target directories (2.13.8) + - name: Inflate target directories (2.13.8, rootJS) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.12.15) + - name: Download target directories (2.13.8, rootJVM) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-2.12.15-${{ matrix.java }} + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM - - name: Inflate target directories (2.12.15) + - name: Inflate target directories (2.13.8, rootJVM) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (3.0.2) + - name: Download target directories (2.12.15, rootJS) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-3.0.2-${{ matrix.java }} + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJS - - name: Inflate target directories (3.0.2) + - name: Inflate target directories (2.12.15, rootJS) run: | tar xf targets.tar rm targets.tar - - name: Import signing key - run: echo $PGP_SECRET | base64 -d | gpg --import - - - run: sbt ++${{ matrix.scala }} release - - - if: matrix.scala == '2.12.15' - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6 - - - if: matrix.scala == '2.12.15' - run: gem update --system - - - if: matrix.scala == '2.12.15' - run: gem install sass - - - if: matrix.scala == '2.12.15' - run: gem install jekyll -v 4 - - - if: matrix.scala == '2.12.15' - run: sbt ++${{ matrix.scala }} docs/publishMicrosite - - scalafmt: - name: Scalafmt - strategy: - matrix: - os: [ubuntu-latest] - scala: [2.13.8, 2.12.15] - java: [temurin@11] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout current branch (full) - uses: actions/checkout@v2 + - name: Download target directories (2.12.15, rootJVM) + uses: actions/download-artifact@v2 with: - fetch-depth: 0 + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM - - name: Setup Java (temurin@8) - if: matrix.java == 'temurin@8' - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: 8 + - name: Inflate target directories (2.12.15, rootJVM) + run: | + tar xf targets.tar + rm targets.tar - - name: Setup Java (temurin@11) - if: matrix.java == 'temurin@11' - uses: actions/setup-java@v2 + - name: Download target directories (3.0.2, rootJS) + uses: actions/download-artifact@v2 with: - distribution: temurin - java-version: 11 + name: target-${{ matrix.os }}-${{ matrix.java }}-3.0.2-rootJS - - name: Cache sbt - uses: actions/cache@v2 - with: - path: | - ~/.sbt - ~/.ivy2/cache - ~/.coursier/cache/v1 - ~/.cache/coursier/v1 - ~/AppData/Local/Coursier/Cache/v1 - ~/Library/Caches/Coursier/v1 - key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Scalafmt - run: sbt ++${{ matrix.scala }} scalafmtCheckAll + - name: Inflate target directories (3.0.2, rootJS) + run: | + tar xf targets.tar + rm targets.tar - headers: - name: Headers - strategy: - matrix: - os: [ubuntu-latest] - scala: [2.13.8, 2.12.15, 3.0.2] - java: [temurin@11] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout current branch (full) - uses: actions/checkout@v2 + - name: Download target directories (3.0.2, rootJVM) + uses: actions/download-artifact@v2 with: - fetch-depth: 0 + name: target-${{ matrix.os }}-${{ matrix.java }}-3.0.2-rootJVM - - name: Setup Java (temurin@8) - if: matrix.java == 'temurin@8' - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: 8 + - name: Inflate target directories (3.0.2, rootJVM) + run: | + tar xf targets.tar + rm targets.tar - - name: Setup Java (temurin@11) - if: matrix.java == 'temurin@11' - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: 11 + - name: Import signing key + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' + run: echo $PGP_SECRET | base64 -d | gpg --import - - name: Cache sbt - uses: actions/cache@v2 - with: - path: | - ~/.sbt - ~/.ivy2/cache - ~/.coursier/cache/v1 - ~/.cache/coursier/v1 - ~/AppData/Local/Coursier/Cache/v1 - ~/Library/Caches/Coursier/v1 - key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + - name: Import signing key and strip passphrase + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != '' + run: | + echo "$PGP_SECRET" | base64 -d > /tmp/signing-key.gpg + echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg + (echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1) - - name: Headers - run: sbt ++${{ matrix.scala }} headerCheckAll + - name: Publish + run: sbt '++${{ matrix.scala }}' tlRelease - microsite: - name: Microsite + site: + name: Generate Site strategy: matrix: os: [ubuntu-latest] - scala: [2.12.15] - java: [temurin@11] + scala: [3.0.2] + java: [temurin@8] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -299,15 +263,13 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6 - - - run: gem update --system + - name: Generate site + run: sbt '++${{ matrix.scala }}' docs/tlSite - - run: gem install sass - - - run: gem install jekyll -v 4 - - - name: Build the microsite - run: sbt ++${{ matrix.scala }} docs/makeMicrosite + - name: Publish site + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + uses: peaceiris/actions-gh-pages@v3.8.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: site/target/docs/site + publish_branch: gh-pages diff --git a/.scalafmt.conf b/.scalafmt.conf index 518bbd94..7dd1b94b 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -28,3 +28,8 @@ rewrite { } runner.dialect = "scala213source3" +fileOverride { + "glob:**/scala-3/**" { + runner.dialect = scala3 + } +} diff --git a/build.sbt b/build.sbt index c05b64b7..1ea0fae6 100644 --- a/build.sbt +++ b/build.sbt @@ -1,84 +1,28 @@ -import sbtghactions.UseRef - val Scala213 = "2.13.8" val Scala212 = "2.12.15" val Scala3 = "3.0.2" -enablePlugins(SonatypeCiReleasePlugin) - -ThisBuild / organization := "org.typelevel" -ThisBuild / organizationName := "Typelevel" -ThisBuild / baseVersion := "2.2" +ThisBuild / tlBaseVersion := "2.2" ThisBuild / crossScalaVersions := Seq(Scala213, Scala212, Scala3) ThisBuild / scalaVersion := Scala213 -ThisBuild / publishFullName := "Christopher Davenport" -ThisBuild / publishGithubUser := "christopherdavenport" - -ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"), JavaSpec.temurin("11")) - -ThisBuild / versionIntroduced := Map( - "2.12" -> "1.2.0", - "2.13" -> "1.2.0", - "3.0.0" -> "1.3.1" -) - -val MicrositesCond = s"matrix.scala == '$Scala212'" - -ThisBuild / githubWorkflowBuild := Seq( - WorkflowStep.Sbt(List("test"), name = Some("Test")), - WorkflowStep.Sbt(List("mimaReportBinaryIssues"), name = Some("Binary Compatibility Check")) -) - -def micrositeWorkflowSteps(cond: Option[String] = None): List[WorkflowStep] = List( - WorkflowStep.Use( - UseRef.Public("ruby", "setup-ruby", "v1"), - params = Map("ruby-version" -> "2.6"), - cond = cond - ), - WorkflowStep.Run(List("gem update --system"), cond = cond), - WorkflowStep.Run(List("gem install sass"), cond = cond), - WorkflowStep.Run(List("gem install jekyll -v 4"), cond = cond) -) - -ThisBuild / githubWorkflowAddedJobs ++= Seq( - WorkflowJob( - "scalafmt", - "Scalafmt", - githubWorkflowJobSetup.value.toList ::: List( - WorkflowStep.Sbt(List("scalafmtCheckAll"), name = Some("Scalafmt")) - ), - // Awaiting release of https://github.com/scalameta/scalafmt/pull/2324/files - scalas = crossScalaVersions.value.toList.filter(_.startsWith("2.")) - ), - WorkflowJob( - "headers", - "Headers", - githubWorkflowJobSetup.value.toList ::: List( - WorkflowStep.Sbt(List("headerCheckAll"), name = Some("Headers")) - ), - scalas = crossScalaVersions.value.toList +ThisBuild / startYear := Some(2018) +ThisBuild / developers := List( + Developer( + "christopherdavenport", + "Christopher Davenport", + "chris@christopherdavenport.tech", + new java.net.URL("https://christopherdavenport.github.io/") ), - WorkflowJob( - "microsite", - "Microsite", - githubWorkflowJobSetup.value.toList ::: (micrositeWorkflowSteps(None) :+ WorkflowStep - .Sbt(List("docs/makeMicrosite"), name = Some("Build the microsite"))), - scalas = List(Scala212) + Developer( + "lorandszakacs", + "Loránd Szakács", + "lorand.szakacs@protonmail.com", + new java.net.URL("https://github.com/lorandszakacs") ) ) +ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"), JavaSpec.temurin("11")) -ThisBuild / githubWorkflowTargetBranches := List("*", "series/*") -ThisBuild / githubWorkflowTargetTags ++= Seq("v*") -ThisBuild / githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))) - -ThisBuild / githubWorkflowPublish := Seq( - WorkflowStep.Sbt( - List("release") - ) -) ++ micrositeWorkflowSteps(Some(MicrositesCond)) :+ WorkflowStep.Sbt( - List("docs/publishMicrosite"), - cond = Some(MicrositesCond) -) +ThisBuild / tlVersionIntroduced := Map("3" -> "2.1.1") val catsV = "2.7.0" val catsEffectV = "3.3.4" @@ -88,65 +32,43 @@ val logbackClassicV = "1.2.10" Global / onChangedBuildSource := ReloadOnSourceChanges -lazy val log4cats = project - .in(file(".")) - .aggregate( - coreJVM, - coreJS, - testingJVM, - testingJS, - noopJVM, - noopJS, - slf4j, - docs - ) - .enablePlugins(NoPublishPlugin) - .settings(commonSettings, releaseSettings) +lazy val root = tlCrossRootProject.aggregate(core, testing, noop, slf4j, docs) lazy val docs = project - .settings(commonSettings, micrositeSettings) - .enablePlugins(MicrositesPlugin) - .enablePlugins(MdocPlugin) - .enablePlugins(NoPublishPlugin) - .settings(mdocIn := sourceDirectory.value / "main" / "mdoc") + .in(file("site")) + .enablePlugins(TypelevelSitePlugin) .dependsOn(slf4j) lazy val core = crossProject(JSPlatform, JVMPlatform) - .settings(commonSettings, releaseSettings) + .settings(commonSettings) .settings( name := "log4cats-core", libraryDependencies ++= Seq( "org.typelevel" %%% "cats-core" % catsV ) ) -lazy val coreJVM = core.jvm -lazy val coreJS = core.js lazy val testing = crossProject(JSPlatform, JVMPlatform) - .settings(commonSettings, releaseSettings) + .settings(commonSettings) .dependsOn(core) .settings( name := "log4cats-testing", libraryDependencies ++= Seq( - "org.typelevel" %%% "cats-effect" % catsEffectV, - "ch.qos.logback" % "logback-classic" % logbackClassicV % Test + "org.typelevel" %%% "cats-effect" % catsEffectV, + "ch.qos.logback" % "logback-classic" % logbackClassicV % Test ) ) -lazy val testingJVM = testing.jvm -lazy val testingJS = testing.js lazy val noop = crossProject(JSPlatform, JVMPlatform) - .settings(commonSettings, releaseSettings) + .settings(commonSettings) .dependsOn(core) .settings( name := "log4cats-noop" ) -lazy val noopJVM = noop.jvm -lazy val noopJS = noop.js lazy val slf4j = project - .settings(commonSettings, releaseSettings) - .dependsOn(coreJVM) + .settings(commonSettings) + .dependsOn(core.js) .settings( name := "log4cats-slf4j", libraryDependencies ++= Seq( @@ -155,7 +77,7 @@ lazy val slf4j = project "ch.qos.logback" % "logback-classic" % logbackClassicV % Test ), libraryDependencies ++= { - if (isDotty.value) Seq.empty + if (tlIsScala3.value) Seq.empty else Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided) } ) @@ -163,67 +85,5 @@ lazy val slf4j = project lazy val commonSettings = Seq( libraryDependencies ++= Seq( "org.typelevel" %%% "munit-cats-effect-3" % munitCatsEffectV % Test - ), - testFrameworks += new TestFramework("munit.Framework"), -) - -lazy val releaseSettings = { - Seq( - Test / publishArtifact := false, - scmInfo := Some( - ScmInfo( - url("https://github.com/typelevel/log4cats"), - "git@github.com:typelevel/log4cats.git" - ) - ), - homepage := Some(url("https://github.com/typelevel/log4cats")), - licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")), - startYear := Some(2018), - developers := List( - Developer( - "christopherdavenport", - "Christopher Davenport", - "chris@christopherdavenport.tech", - new java.net.URL("https://christopherdavenport.github.io/") - ), - Developer( - "lorandszakacs", - "Loránd Szakács", - "lorand.szakacs@protonmail.com", - new java.net.URL("https://github.com/lorandszakacs") - ) - ) ) -} - -lazy val micrositeSettings = Seq( - micrositeName := "log4cats", - micrositeDescription := "Functional Logging", - micrositeAuthor := "Christopher Davenport", - micrositeGithubOwner := "typelevel", - micrositeGithubRepo := "log4cats", - micrositeBaseUrl := "/log4cats", - micrositeDocumentationUrl := "https://typelevel.github.io/log4cats", - micrositeFooterText := None, - micrositeHighlightTheme := "atom-one-light", - micrositePalette := Map( - "brand-primary" -> "#3e5b95", - "brand-secondary" -> "#294066", - "brand-tertiary" -> "#2d5799", - "gray-dark" -> "#49494B", - "gray" -> "#7B7B7E", - "gray-light" -> "#E5E5E6", - "gray-lighter" -> "#F4F3F4", - "white-color" -> "#FFFFFF" - ), - scalacOptions --= Seq( - "-Xfatal-warnings", - "-Ywarn-unused-import", - "-Ywarn-numeric-widen", - "-Ywarn-dead-code", - "-Ywarn-unused:imports", - "-Xlint:-missing-interpolator,_" - ), - micrositePushSiteWith := GitHub4s, - micrositeGithubToken := sys.env.get("GITHUB_TOKEN") ) diff --git a/docs/Gemfile b/docs/Gemfile deleted file mode 100644 index 2f79a7b2..00000000 --- a/docs/Gemfile +++ /dev/null @@ -1,4 +0,0 @@ -source 'http://rubygems.org' - -gem "jekyll", ">= 4.0.0" -gem "jekyll-relative-links" \ No newline at end of file diff --git a/docs/src/main/mdoc/index.md b/docs/index.md similarity index 87% rename from docs/src/main/mdoc/index.md rename to docs/index.md index 86a7f9b1..894ae528 100644 --- a/docs/src/main/mdoc/index.md +++ b/docs/index.md @@ -1,8 +1,6 @@ ---- -layout: home +# log4cats ---- -# log4cats [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.typelevel/log4cats-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.typelevel/log4cats-core_2.12) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.typelevel/log4cats-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.typelevel/log4cats-core_2.12) ## Project Goals @@ -17,8 +15,8 @@ To use log4cats in an existing SBT project with Scala 2.12 or a later version, a ```scala libraryDependencies ++= Seq( - "org.typelevel" %% "log4cats-core" % "", // Only if you want to Support Any Backend - "org.typelevel" %% "log4cats-slf4j" % "", // Direct Slf4j Support - Recommended + "org.typelevel" %% "log4cats-core" % "@VERSION@", // Only if you want to Support Any Backend + "org.typelevel" %% "log4cats-slf4j" % "@VERSION@", // Direct Slf4j Support - Recommended ) ``` @@ -32,7 +30,7 @@ import cats.implicits._ object MyThing { // Impure But What 90% of Folks I know do with log4s - implicit def logger[F[_]: Sync] = Slf4jLogger.getLogger[F] + implicit def logger[F[_]: Sync]: Logger[F] = Slf4jLogger.getLogger[F] // Arbitrary Local Function Declaration def doSomething[F[_]: Sync]: F[Unit] = diff --git a/project/plugins.sbt b/project/plugins.sbt index 4455dd39..b1d2962b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,8 +1,5 @@ -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") -addSbtPlugin("com.47deg" % "sbt-microsites" % "1.3.4") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.24") -addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.23.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") +val sbtTypelevelVersion = "0.4.3" +addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion) +addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion) diff --git a/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/Slf4jLogger.scala b/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/Slf4jLogger.scala index c2599b51..e6bd319d 100644 --- a/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/Slf4jLogger.scala +++ b/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/Slf4jLogger.scala @@ -24,19 +24,19 @@ import org.slf4j.{Logger => JLogger} object Slf4jLogger { inline def getLogger[F[_]](implicit F: Sync[F]): SelfAwareStructuredLogger[F] = - ${GetLoggerMacros.getLoggerImpl('F)} + ${ GetLoggerMacros.getLoggerImpl('F) } def getLoggerFromName[F[_]: Sync](name: String): SelfAwareStructuredLogger[F] = getLoggerFromSlf4j(org.slf4j.LoggerFactory.getLogger(name)) def getLoggerFromClass[F[_]: Sync](clazz: Class[_]): SelfAwareStructuredLogger[F] = getLoggerFromSlf4j[F](org.slf4j.LoggerFactory.getLogger(clazz)) - + def getLoggerFromSlf4j[F[_]: Sync](logger: JLogger): SelfAwareStructuredLogger[F] = new Slf4jLoggerInternal.Slf4jLogger(logger) inline def create[F[_]](implicit F: Sync[F]): F[SelfAwareStructuredLogger[F]] = - ${GetLoggerMacros.createImpl('F)} + ${ GetLoggerMacros.createImpl('F) } def fromName[F[_]: Sync](name: String): F[SelfAwareStructuredLogger[F]] = Sync[F].delay(getLoggerFromName(name)) diff --git a/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/internal/GetLoggerMacros.scala b/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/internal/GetLoggerMacros.scala index d4bb1edd..26129b96 100644 --- a/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/internal/GetLoggerMacros.scala +++ b/slf4j/src/main/scala-3/org/typelevel/log4cats/slf4j/internal/GetLoggerMacros.scala @@ -25,7 +25,9 @@ import scala.quoted._ private[slf4j] object GetLoggerMacros { - def getLoggerImpl[F[_]: Type](F: Expr[Sync[F]])(using qctx: Quotes): Expr[SelfAwareStructuredLogger[F]] = { + def getLoggerImpl[F[_]: Type]( + F: Expr[Sync[F]] + )(using qctx: Quotes): Expr[SelfAwareStructuredLogger[F]] = { import qctx.reflect._ @tailrec def findEnclosingClass(sym: Symbol): Symbol = { @@ -45,22 +47,18 @@ private[slf4j] object GetLoggerMacros { val flags = s.flags if (flags.is(Flags.Package)) { s.fullName - } - else if (s.isClassDef) { + } else if (s.isClassDef) { if (flags.is(Flags.Module)) { if (s.name == "package$") { fullName(s.owner) - } - else { + } else { val chomped = s.name.stripSuffix("$") fullName(s.owner) + "." + chomped } - } - else { + } else { fullName(s.owner) + "." + s.name } - } - else { + } else { fullName(s.owner) } } @@ -73,8 +71,10 @@ private[slf4j] object GetLoggerMacros { logger(cls) } - def createImpl[F[_]: Type](F: Expr[Sync[F]])(using qctx: Quotes): Expr[F[SelfAwareStructuredLogger[F]]] = { + def createImpl[F[_]: Type]( + F: Expr[Sync[F]] + )(using qctx: Quotes): Expr[F[SelfAwareStructuredLogger[F]]] = { val logger = getLoggerImpl(F) - '{$F.delay($logger)} + '{ $F.delay($logger) } } }