Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: LEGO/woof
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.4.4
Choose a base ref
...
head repository: LEGO/woof
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Apr 27, 2022

  1. Copy the full SHA
    2a6a965 View commit details
  2. Refresh mdoc

    hejfelix committed Apr 27, 2022
    Copy the full SHA
    b4a33cb View commit details

Commits on May 17, 2022

  1. Copy the full SHA
    26f16cd View commit details
  2. Copy the full SHA
    e4a641f View commit details
  3. Copy the full SHA
    e76f775 View commit details
  4. Upgrade http4s-core from 0.23.9 to 0.23.11 (#56)

    * Upgrade http4s-core from 0.23.9 to 0.23.11
    
    * Revert commit(s) 55119de
    
    * Upgrade http4s-core from 0.23.9 to 0.23.11
    
    Co-authored-by: Felix Bjært Hargreaves <hejfelix@users.noreply.github.com>
    scala-steward and hejfelix authored May 17, 2022
    Copy the full SHA
    8c8d5f8 View commit details
  5. Upgrade slf4j-api from 1.7.35 to 1.7.36 (#48)

    * Upgrade slf4j-api from 1.7.35 to 1.7.36
    
    * Revert commit(s) bf69cab
    
    * Upgrade slf4j-api from 1.7.35 to 1.7.36
    
    Co-authored-by: Felix Bjært Hargreaves <hejfelix@users.noreply.github.com>
    scala-steward and hejfelix authored May 17, 2022
    Copy the full SHA
    49d9639 View commit details
  6. Upgrade scalafmt-core from 3.4.3 to 3.5.3 (#67)

    * Upgrade scalafmt-core from 3.4.3 to 3.5.3
    
    * Reformat with scalafmt 3.5.3
    
    * Fix tests after scalafmt ugrade
    
    Co-authored-by: Felix <felix.palludan.hargreaves@lego.com>
    scala-steward and hejfelix authored May 17, 2022
    Copy the full SHA
    2e59cf9 View commit details
  7. Copy the full SHA
    5340dbf View commit details

Commits on May 19, 2022

  1. Markdown linting (#69)

    * Run MarkDown linting and fix warnings.
    
    * Generate README with mdoc.
    Colin-TUE authored May 19, 2022
    Copy the full SHA
    2f0e264 View commit details
  2. Add Contributing.md (#71)

    * Add Contributing.md:
    
    added section on hos to update the README.
    
    * Remove leftovers from copy-paste.
    Colin-TUE authored May 19, 2022
    Copy the full SHA
    b81842d View commit details

Commits on May 20, 2022

  1. Copy the full SHA
    7caece6 View commit details
  2. Add tagless final example

    hejfelix committed May 20, 2022
    Copy the full SHA
    f110e22 View commit details
  3. Add CustomPrinter example

    hejfelix committed May 20, 2022
    Copy the full SHA
    ec9eb4f View commit details
  4. Copy the full SHA
    01dddb9 View commit details
  5. Add AtLeastLevel example

    unicojoyhug authored and hejfelix committed May 20, 2022
    Copy the full SHA
    0f01e67 View commit details
  6. Add scalajs hello world

    hejfelix committed May 20, 2022
    Copy the full SHA
    def2fc5 View commit details
  7. Copy the full SHA
    a5a4cf3 View commit details
  8. adding more LogFilter examples

    LMarkowski authored and hejfelix committed May 20, 2022
    Copy the full SHA
    862e519 View commit details
  9. Copy the full SHA
    77ec008 View commit details
  10. Copy the full SHA
    cb532a2 View commit details
  11. Add examples/FileOutput.scala

    kheino authored and hejfelix committed May 20, 2022
    Copy the full SHA
    bb48f28 View commit details
  12. Update README.md

    kheino authored and hejfelix committed May 20, 2022
    Copy the full SHA
    4b4208a View commit details
  13. Copy the full SHA
    3ff3945 View commit details
  14. format build.sbt

    hejfelix committed May 20, 2022
    Copy the full SHA
    b420136 View commit details
  15. Fix typo

    hejfelix committed May 20, 2022
    Copy the full SHA
    f9a6e25 View commit details

Commits on Jun 1, 2022

  1. Copy the full SHA
    7e6e779 View commit details
  2. Copy the full SHA
    130f786 View commit details

Commits on Jul 7, 2022

  1. Copy the full SHA
    acd539a View commit details

Commits on Jul 8, 2022

  1. Copy the full SHA
    2d6052d View commit details
  2. Copy the full SHA
    c4a8cb1 View commit details
  3. Copy the full SHA
    7be9ee4 View commit details
  4. Copy the full SHA
    cd3f98e View commit details
  5. Copy the full SHA
    8562c43 View commit details
  6. Merge pull request #81 from scala-steward/update/cats-effect-3.3.13

    Upgrade cats-effect, cats-effect-testkit from 3.3.12 to 3.3.13
    hejfelix authored Jul 8, 2022
    Copy the full SHA
    7a63acd View commit details
  7. Copy the full SHA
    a044605 View commit details
  8. Reformat with scalafmt 3.5.8

    Executed command: scalafmt --non-interactive
    scala-steward authored and hejfelix committed Jul 8, 2022
    Copy the full SHA
    960cee9 View commit details
  9. Copy the full SHA
    83c16ec View commit details

Commits on Jul 14, 2022

  1. Upgrade sbt from 1.6.2 to 1.7.1

    scala-steward authored and hejfelix committed Jul 14, 2022
    Copy the full SHA
    fcb3d70 View commit details
  2. Copy the full SHA
    9dd03a1 View commit details

Commits on Aug 8, 2022

  1. Copy the full SHA
    7e7489f View commit details
  2. Copy the full SHA
    03fcf54 View commit details

Commits on Aug 12, 2022

  1. Copy the full SHA
    b300d51 View commit details

Commits on Aug 24, 2022

  1. Copy the full SHA
    fd85ab4 View commit details

Commits on Sep 7, 2022

  1. Copy the full SHA
    8ad2a23 View commit details

Commits on Sep 8, 2022

  1. Copy the full SHA
    18a2492 View commit details
  2. Copy the full SHA
    cde9637 View commit details
  3. Copy the full SHA
    f9b0e33 View commit details

Commits on Sep 26, 2022

  1. Cross-build for Scala Native

    kubukoz authored and hejfelix committed Sep 26, 2022
    Copy the full SHA
    0c455ce View commit details
  2. Aggregate all projects

    kubukoz authored and hejfelix committed Sep 26, 2022
    Copy the full SHA
    1eb7a27 View commit details
Showing with 1,173 additions and 278 deletions.
  1. +5 −0 .git-blame-ignore-revs
  2. +6 −2 .github/workflows/release.yml
  3. +2 −2 .github/workflows/scala.yml
  4. +1 −0 .sbtopts
  5. +1 −0 .scala-steward.conf
  6. +1 −1 .scalafmt.conf
  7. +13 −1 CONTRIBUTING.md
  8. +76 −37 README.md
  9. +48 −0 REGENERATING_SIGNING_KEY.md
  10. +62 −18 build.sbt
  11. +60 −19 docs/README.md
  12. +70 −0 modules/benchmarks/FilterBenchmark.scala.output.md
  13. +49 −0 modules/benchmarks/src/main/scala/benchmarks/FilterBenchmark.scala
  14. 0 modules/core/{jvm → jvm-native}/src/main/scala/org/legogroup/woof/DefaultTimeFormat.scala
  15. 0 modules/core/{jvm → jvm-native}/src/test/scala/org/legogroup/woof/TestFormatTime.scala
  16. +59 −0 modules/core/shared/src/main/scala/org/legogroup/woof/DefaultLogger.scala
  17. +22 −10 modules/core/shared/src/main/scala/org/legogroup/woof/Filter.scala
  18. +5 −48 modules/core/shared/src/main/scala/org/legogroup/woof/Logger.scala
  19. +2 −2 modules/core/shared/src/main/scala/org/legogroup/woof/Macro.scala
  20. +1 −0 modules/core/shared/src/main/scala/org/legogroup/woof/json/JsonSupport.scala
  21. +2 −1 modules/core/shared/src/test/scala/org/legogroup/woof/FilterSuite.scala
  22. +33 −11 modules/core/shared/src/test/scala/org/legogroup/woof/LoggerSuite.scala
  23. +6 −3 modules/core/shared/src/test/scala/org/legogroup/woof/json/JsonSupportSuite.scala
  24. +11 −0 modules/examples-scalajs/index.html
  25. +20 −0 modules/examples-scalajs/src/main/scala/examples/HelloScalaJs.scala
  26. +25 −0 modules/examples/src/main/scala/examples/CustomPrinter.scala
  27. +37 −0 modules/examples/src/main/scala/examples/CustomTheme.scala
  28. +32 −0 modules/examples/src/main/scala/examples/FileOutput.scala
  29. +17 −0 modules/examples/src/main/scala/examples/HelloWorld.scala
  30. +24 −0 modules/examples/src/main/scala/examples/LogLevelFromEnv.scala
  31. +31 −0 modules/examples/src/main/scala/examples/TaglessFinal.scala
  32. +33 −0 modules/examples/src/main/scala/examples/filters/AtLeastLevel.scala
  33. +46 −0 modules/examples/src/main/scala/examples/filters/CustomFilter.scala
  34. +33 −0 modules/examples/src/main/scala/examples/filters/ExactLevel.scala
  35. +43 −0 modules/examples/src/main/scala/examples/filters/RegexFilter.scala
  36. +3 −7 modules/http4s/src/main/scala/org/legogroup/woof/http4s/CorrelationIdMiddleware.scala
  37. +4 −4 modules/http4s/src/test/scala/org/legogroup/woof/http4s/CorrelationIdMiddlewareSuite.scala
  38. +1 −0 modules/slf4j-2/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider
  39. +29 −0 modules/slf4j-2/src/main/scala/org/legogroup/woof/slf4j2/WoofLogger.scala
  40. +8 −0 modules/slf4j-2/src/main/scala/org/legogroup/woof/slf4j2/WoofLoggerServiceProvider.scala
  41. +1 −0 modules/slf4j-2/src/test/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider
  42. +105 −0 modules/slf4j-2/src/test/scala/org/legogroup/woof/slf4j2/Slf4j2Suite.scala
  43. +108 −0 modules/slf4j-common/src/main/scala/org/legogroup/woof/slf4j/Slf4jWoofLoggerImpl.scala
  44. +12 −96 modules/slf4j/src/main/scala/org/legogroup/woof/slf4j/WoofLogger.scala
  45. +3 −1 modules/slf4j/src/main/scala/org/slf4j/impl/StaticLoggerBinder.scala
  46. +12 −9 modules/slf4j/src/test/scala/org/legogroup/woof/slf4j/Slf4jSuite.scala
  47. +1 −1 project/build.properties
  48. +10 −5 project/plugins.sbt
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Scala Steward: Reformat with scalafmt 3.5.8
5b62465aa83c45f7c20487b73c633a9024569259

# Scala Steward: Reformat with scalafmt 3.7.3
c9a0b2b472e054c270e87cccf81c3cc5b96960aa
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -7,10 +7,14 @@ jobs:
publish:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: olafurpg/setup-scala@v13
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
4 changes: 2 additions & 2 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
@@ -10,9 +10,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK 16
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: "16"
distribution: "adopt"
1 change: 1 addition & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-J-Xmx4G
1 change: 1 addition & 0 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
commits.message = "Upgrade ${artifactName} from ${currentVersion} to ${nextVersion}"
updatePullRequests = "always"
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.4.0
version = 3.8.3

runner.dialect = scala3

14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
sbt scalafmt test -mem 2048
# How to contribute

## Welcome

:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:

The following is a set of guides for contributing and feel free to propose changes to this document in a pull request.

Happy to have you onboard :+1:

## How to update the README.md

The README is generated using [mdoc]() from the README source so that all code examples are compiled, run, and its output added to the code block. When updating the README the source needs to be updated, which can be found in [/docs/](docs/README.md). Then one needs to regenerate the README using the `sbt:root> docs/mdoc` command.
113 changes: 76 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,29 +5,68 @@

A **pure** _(in both senses of the word!)_ **Scala 3** logging library with **no runtime reflection**.

![](dog-svgrepo-com.svg)
![logo](dog-svgrepo-com.svg)

# Table of Contents
- [Highlights](#highlights)
- [Cross platform](#cross-platform)
- [Installation](#installation)
- [Example](#example)
- [Can I use `SLF4J`?](#can-i-use-slf4j)
- [Limitations of SLF4J bindings](#limitations-of-slf4j-bindings)
- [Can I use `http4s`?](#can-i-use-http4s)
- [Structured Logging](#structured-logging)

## Highlights

* Pure **Scala 3** library
* Made with _Cats Effect_
* Macro based (_no runtime reflection_)
* ~~Can be built for _scala.js_ in the future!~~
* Cross-built for `Scala.js`
* Configured with plain Scala code

### Cross platform

| Module | JVM | scala.js | native |
|---------|-------|-----------|--------|
| core ||||
| http4s ||||
| slf4j || 🚫 | 🚫 |
| slf4j-2 || 🚫 | 🚫 |

## Installation

> build.sbt
```scala
libraryDependencies ++= Seq(
"org.legogroup" %% "woof-core" % "$VERSION",
"org.legogroup" %% "woof-slf4j" % "$VERSION", // only if you need to use Woof via slf4j
"org.legogroup" %% "woof-http4s" % "$VERSION", // only if you need to add correlation IDs in http4s
"org.legogroup" %% "woof-core" % "$VERSION",
"org.legogroup" %% "woof-slf4j" % "$VERSION", // only if you need to use Woof via slf4j 1.x.x
"org.legogroup" %% "woof-slf4j-2" % "$VERSION", // only if you need to use Woof via slf4j 2.x.x
"org.legogroup" %% "woof-http4s" % "$VERSION", // only if you need to add correlation IDs in http4s
)
```

You can see a bunch of self-contained examples in the [examples](modules/examples) sub-project. To run them, open `sbt` and run the command `examples/run`:

```
sbt:root> examples/run
Multiple main classes detected. Select one to run:
[1] examples.AtLeastLevel
[2] examples.CustomPrinter
[3] examples.CustomTheme
[4] examples.ExactLevel
[5] examples.FileOutput
[6] examples.HelloWorld
[7] examples.LogLevelFromEnv
[8] examples.RegexFilter
[9] examples.TaglessFinal
Enter number:
```

it will ask you for a number corresponding to the example you wish to run. For a self-contained `Scala.Js` example, look at [modules/examples-scalajs/src/main/scala/examples/HelloScalaJs.scala](modules/examples-scalajs/src/main/scala/examples/HelloScalaJs.scala)

## Example

```scala
@@ -61,13 +100,12 @@ and running it yields:
```scala
import cats.effect.unsafe.implicits.global
main.unsafeRunSync()
// 2022-04-21 08:47:11 [DEBUG] repl.MdocSession$.App: This is some debug (.:27)
// 2022-04-21 08:47:11 [INFO ] repl.MdocSession$.App: HEY! (.:28)
// 2022-04-21 08:47:11 [WARN ] repl.MdocSession$.App: I'm warning you (.:29)
// 2022-04-21 08:47:11 [ERROR] repl.MdocSession$.App: I give up (.:30)
// 2023-03-13 09:00:42 [DEBUG] repl.MdocSession$.MdocApp: This is some debug (README.md:27)
// 2023-03-13 09:00:42 [INFO ] repl.MdocSession$.MdocApp: HEY! (README.md:28)
// 2023-03-13 09:00:42 [WARN ] repl.MdocSession$.MdocApp: I'm warning you (README.md:29)
// 2023-03-13 09:00:42 [ERROR] repl.MdocSession$.MdocApp: I give up (README.md:30)
```


We can also re-use the program and add context to our logger:

```scala
@@ -84,14 +122,14 @@ And running with context yields:

```scala
mainWithContext.unsafeRunSync()
// 2022-04-21 08:47:11 [DEBUG] trace-id=4d334544-6462-43fa-b0b1-12846f871573 repl.MdocSession$.App: This is some debug (.:27)
// 2022-04-21 08:47:11 [INFO ] trace-id=4d334544-6462-43fa-b0b1-12846f871573 repl.MdocSession$.App: HEY! (.:28)
// 2022-04-21 08:47:11 [WARN ] trace-id=4d334544-6462-43fa-b0b1-12846f871573 repl.MdocSession$.App: I'm warning you (.:29)
// 2022-04-21 08:47:11 [ERROR] trace-id=4d334544-6462-43fa-b0b1-12846f871573 repl.MdocSession$.App: I give up (.:30)
// 2022-04-21 08:47:11 [INFO ] repl.MdocSession$.App: Now the context is gone (.:61)
// 2023-03-13 09:00:42 [DEBUG] trace-id=4d334544-6462-43fa-b0b1-12846f871573 repl.MdocSession$.MdocApp: This is some debug (README.md:27)
// 2023-03-13 09:00:42 [INFO ] trace-id=4d334544-6462-43fa-b0b1-12846f871573 repl.MdocSession$.MdocApp: HEY! (README.md:28)
// 2023-03-13 09:00:42 [WARN ] trace-id=4d334544-6462-43fa-b0b1-12846f871573 repl.MdocSession$.MdocApp: I'm warning you (README.md:29)
// 2023-03-13 09:00:42 [ERROR] trace-id=4d334544-6462-43fa-b0b1-12846f871573 repl.MdocSession$.MdocApp: I give up (README.md:30)
// 2023-03-13 09:00:42 [INFO ] repl.MdocSession$.MdocApp: Now the context is gone (README.md:61)
```

# Can I use SLF4J?
## Can I use `SLF4J`?

Yes, you can. I don't think you should (for new projects), but you can use it for interop with existing SLF4J programs! Note, however, that not everything can be implemented perfectly against the
`SLF4J` API, e.g. the filtering functionality in `woof` is much more flexible and thus does not map directly to, e.g., `isDebugEnabled`.
@@ -120,26 +158,28 @@ To use this program with woof
```scala
import org.legogroup.woof.slf4j.*
import cats.effect.std.Dispatcher
val mainSlf4j: IO[Unit] =
for
woofLogger <- DefaultLogger.makeIo(consoleOutput)
_ <- woofLogger.registerSlf4j
_ <- programWithSlf4j
yield ()
Dispatcher.sequential[IO].use{ implicit dispatcher =>
for
woofLogger <- DefaultLogger.makeIo(consoleOutput)
_ <- woofLogger.registerSlf4j
_ <- programWithSlf4j
yield ()
}
```

and running it:

```scala
mainSlf4j.unsafeRunSync()
// 2022-04-21 08:47:11 [INFO ] repl.MdocSession$App: Hello from SLF4j! (MdocSession$App.scala:81)
// 2022-04-21 08:47:11 [WARN ] repl.MdocSession$App: This is not the pure woof. (MdocSession$App.scala:82)
```
## Limitations of SLF4J bindings

### Limitations of SLF4J bindings

Currently, markers do nothing. You can get the same behaviour easily with context when using the direct `woof` api with filters and printers.

# Can I use __http4s__?
## Can I use `http4s`?

Yes you can. If you want to see internal logs from `http4s`, use the `SLF4J` module from above. If you want to use the context capabilities in `woof`, there's a module for adding correlation IDs to each request with a simple middleware.

@@ -177,20 +217,20 @@ val mainHttp4s: IO[Unit] =
yield ()
```

Finally, running it, we see that the correlation ID is added to the log message inside the routes (transparently), and that
Finally, running it, we see that the correlation ID is added to the log message inside the routes (transparently), and that
the correlation ID is also returned in the header of the response.

> NOTE: The correlation ID is _not_ present outside the routes, i.e. we have scoped it only to the service part of our code.
```scala
mainHttp4s.unsafeRunSync()
// 2022-04-21 08:47:12 [INFO ] X-Trace-Id=f9780ca5-2e41-445e-96c7-335822d2143b repl.MdocSession$.App: I got a request with trace id! :D (.:121)
// 2022-04-21 08:47:12 [INFO ] repl.MdocSession$.App: Got response headers: Headers(X-Trace-Id: f9780ca5-2e41-445e-96c7-335822d2143b) (.:142)
// 2023-03-13 09:00:43 [INFO ] X-Trace-Id=33a38390-647a-4876-9a05-7898a8f4db44 repl.MdocSession$.MdocApp: I got a request with trace id! :D (README.md:126)
// 2023-03-13 09:00:43 [INFO ] repl.MdocSession$.MdocApp: Got response headers: Headers(X-Trace-Id: 33a38390-647a-4876-9a05-7898a8f4db44) (README.md:147)
```

## Structured Logging

Structured logging is useful when your logs are collected and inspected by a monitoring system. Having a well structured log output can save you
Structured logging is useful when your logs are collected and inspected by a monitoring system. Having a well structured log output can save you
hours of reg-ex'ing your way towards the root cause of a burning issue.

`Woof` supports printing as `Json`:
@@ -210,12 +250,11 @@ And running with context yields:

```scala
contextAsJson.unsafeRunSync()
// {"level":"Debug","epochMillis":1650523632092,"timeStamp":"2022-04-21T06:47:12Z","enclosingClass":"repl.MdocSession$.App","message":"This is some debug","context":{"bar":"1337","foo":"42"}}
// {"level":"Info","epochMillis":1650523632096,"timeStamp":"2022-04-21T06:47:12Z","enclosingClass":"repl.MdocSession$.App","message":"HEY!","context":{"bar":"1337","foo":"42"}}
// {"level":"Warn","epochMillis":1650523632096,"timeStamp":"2022-04-21T06:47:12Z","enclosingClass":"repl.MdocSession$.App","message":"I'm warning you","context":{"bar":"1337","foo":"42"}}
// {"level":"Error","epochMillis":1650523632096,"timeStamp":"2022-04-21T06:47:12Z","enclosingClass":"repl.MdocSession$.App","message":"I give up","context":{"bar":"1337","foo":"42"}}
// {"level":"Info","epochMillis":1650523632097,"timeStamp":"2022-04-21T06:47:12Z","enclosingClass":"repl.MdocSession$.App","message":"Now the context is gone","context":{}}
// {"level":"Debug","epochMillis":1678694443157,"timeStamp":"2023-03-13T08:00:43Z","enclosingClass":"repl.MdocSession$.MdocApp","lineNumber":26,"message":"This is some debug","context":{"bar":"1337","foo":"42"}}
// {"level":"Info","epochMillis":1678694443159,"timeStamp":"2023-03-13T08:00:43Z","enclosingClass":"repl.MdocSession$.MdocApp","lineNumber":27,"message":"HEY!","context":{"bar":"1337","foo":"42"}}
// {"level":"Warn","epochMillis":1678694443159,"timeStamp":"2023-03-13T08:00:43Z","enclosingClass":"repl.MdocSession$.MdocApp","lineNumber":28,"message":"I'm warning you","context":{"bar":"1337","foo":"42"}}
// {"level":"Error","epochMillis":1678694443159,"timeStamp":"2023-03-13T08:00:43Z","enclosingClass":"repl.MdocSession$.MdocApp","lineNumber":29,"message":"I give up","context":{"bar":"1337","foo":"42"}}
// {"level":"Info","epochMillis":1678694443159,"timeStamp":"2023-03-13T08:00:43Z","enclosingClass":"repl.MdocSession$.MdocApp","lineNumber":168,"message":"Now the context is gone","context":{}}
```


> We are considering if we should support matching different printers with different outputs: Maybe you want human readable logs for standard out and structured logging for your monitoring tools. However, this will be a breaking change.
> We are considering if we should support matching different printers with different outputs: Maybe you want human readable logs for standard out and structured logging for your monitoring tools. However, this will be a breaking change.
48 changes: 48 additions & 0 deletions REGENERATING_SIGNING_KEY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Regenerating the GPG signing key

The key for signing releases expires every year.
To sign a new release _after the key expires_, you need to:

1. Generate a new key
2. Publish the public signature to one or more key servers: (e.g. https://keyserver.ubuntu.com/)

## Generating a new key

We use a password protected, encrypted signing key when signing releases for maven central. To refresh the key, you need to:

1. Download the secret key file from your secret manager
1. Note the encryption password from your secret manager
1. Import the key into your local gpg keychain
1. `gpg --import <path to secret key file>`
1. Enter the encryption password when prompted
1. List the secret key ids: `gpg --list-secret-keys --keyid-format LONG`
1. Note the key ID of the imported key
1. Refresh the key expiration date
1. `gpg --edit-key <key id>`
1. `expire`
1. **IMPORTANT:** When promted, write `1y`. The default is `no-expiration`, **which is not what we want**
1. You should be prompted for the pass-phrase again. Enter the same pass-phrase as before
1. `save` + enter
1. If done correctly, it should exit the `gpg` interactive prompt

## Update the key in your secret manager

1. Export the public key: `gpg --output maven.public.gpg --armor --export <key id>`
1. Export the private key: `gpg --output maven.secret.gpg --armor --export-secret-keys <key id>`
1. You will be prompted for the pass-phrase. Enter the same pass-phrase as before
1. Rename the existing public and private keys in your secret manager to something like `maven.public.gpg[expired]`
1. You can delete the `n-2`nd iteration of keys, as we are pretty sure we won't need them again at this point
1. Upload `maven.public.gpg` and `maven.secret.gpg` to your secret manager
1. **IMPORTANT** Delete `maven.public.gpg` and `maven.secret.gpg` from your local machine

## Publish the public key to a key server

1. `gpg --keyserver hkp://keyserver.ubuntu.com --send-key <key id>`

Now the downstream clients can verify the signature of the artifacts you sign with this key.

## Update the secret environment variables in the github action

1. Copy the `base64` encoded secret key from your secret manager
1. `gpg --armor --export-secret-keys $LONG_ID | base64 | pbcopy`
1. Paste the `base64` encoded secret key into the `PGP_SECRET` secret variable in the github action
Loading