diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53ebc04b..f4158bf7 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,21 +71,40 @@ 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')) + 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')) + 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')) 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: @@ -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' && startsWith(github.ref, 'refs/tags/v') + 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 abb9de48..7f958e28 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -28,3 +28,8 @@ rewrite { } runner.dialect = "scala213source3" +fileOverride { + "glob:**/scala-3/**" { + runner.dialect = scala3 + } +} \ No newline at end of file diff --git a/build.sbt b/build.sbt index 0c8ad3eb..fc6311f2 100644 --- a/build.sbt +++ b/build.sbt @@ -1,83 +1,33 @@ -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 := "1.5" +ThisBuild / tlBaseVersion := "1.5" 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 / tlSitePublishBranch := None +ThisBuild / tlCiReleaseBranches := Seq() +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( + "2.12" -> "1.2.0", + "2.13" -> "1.2.0", + "3" -> "1.3.1" ) val catsV = "2.7.0" @@ -88,64 +38,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 + "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( @@ -154,7 +83,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,69 +92,7 @@ lazy val commonSettings = Seq( libraryDependencies ++= Seq( "org.typelevel" %%% "munit-cats-effect-2" % munitCatsEffectV % Test ), - testFrameworks += new TestFramework("munit.Framework"), mimaPreviousArtifacts ~= { xs => xs.filterNot(_.revision == "1.5.0") // cursed tag } ) - -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", - "lorandszakacs@users.noreply.github.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/src/main/mdoc/index.md index 9a6c1827..4ade50bb 100644 --- a/docs/src/main/mdoc/index.md +++ b/docs/src/main/mdoc/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 @@ -12,13 +10,13 @@ or you can use any of the supported backends, or create your own. ## Quick Start -To use log4cats in an existing SBT project with Scala 2.11 or a later version, add the following dependency to your +To use log4cats in an existing SBT project with Scala 2.12 or a later version, add the following dependency to your `build.sbt`: ```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 unsafeLogger[F[_]: Sync] = Slf4jLogger.unsafeCreate[F] + implicit def logger[F[_]: Sync]: Logger[F] = Slf4jLogger.getLogger[F] // Arbitrary Local Function Declaration def doSomething[F[_]: Sync]: F[Unit] = @@ -62,7 +60,7 @@ def passForEasierUse[F[_]: Sync: Logger] = for { ### Laconic syntax -It's possible to use interpolated syntax for logging. +It's possible to use interpolated syntax for logging. Currently, supported ops are: `trace`, `debug`, `info`, `warn`, `error`. You can use it for your custom `Logger` as well as for Slf4j `Logger`. @@ -83,4 +81,15 @@ def log[F[_]: Sync: Logger] = case _ => error"We got an error!" } } yield () -``` \ No newline at end of file +``` + +## CVE-2021-44228 ("log4shell") + +log4cats is not directly susceptible to CVS-2021-44228. The +log4cats-slf4j implementation delegates all logging operations to +[slf4j][slf4j]. if you use log4cats-slf4j, your configured slf4j +provider may put you at risk. See [slf4j's comments on +CVE-2021-44228][slf4j-log4shell] for more. + +[slf4j]: https://www.slf4j.org/ +[slf4j-log4shell]: https://www.slf4j.org/log4shell.html \ No newline at end of file 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 ce7b838a..8d4f41f4 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,11 +24,11 @@ import org.slf4j.{Logger => JLogger} object Slf4jLogger { inline def getLogger[F[_]](implicit F: Sync[F]): SelfAwareStructuredLogger[F] = - ${GetLoggerMacros.getLoggerImpl('F)} + ${ GetLoggerMacros.getLoggerImpl('F) } @deprecated("0.3.0", "Use getLogger instead") inline def unsafeCreate[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)) @@ -43,7 +43,7 @@ object Slf4jLogger { @deprecated("0.3.0", "Use getLoggerFromClass") def unsafeFromClass[F[_]: Sync](clazz: Class[_]): SelfAwareStructuredLogger[F] = getLoggerFromClass[F](clazz) - + def getLoggerFromSlf4j[F[_]: Sync](logger: JLogger): SelfAwareStructuredLogger[F] = new Slf4jLoggerInternal.Slf4jLogger(logger) @@ -52,7 +52,7 @@ object Slf4jLogger { getLoggerFromSlf4j[F](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) } } }