Skip to content

Conversation

@road21
Copy link

@road21 road21 commented May 31, 2023

This pull request provides basic support for derivation LogstageCodec from izumi.logstage library.

Quick example:

@SnakeCase
@Discriminator("type")
enum User derives Config, EvoLog:
  case AuthorizedClient(@Rename("client_id") id: Long, name: String, @Masked token: String)
  case Anonymous

import logstage.IzLogger
val logger = IzLogger()
val user = User.AuthorizedClient(100, "Bob", "123")

import evo.derivation.logstage.instances.given // arggh
logger.trace(s"User: $user")

Will print:

T 2023-06-08T18:45:34.795 (LogstageTest.scala:27)  …ation.logstage.LogstageTest [1:main] User: user={type: authorized_client; client_id: 100; name: Bob; token: ***masked***}

The problem is that LogstageCodec is contravariant, so EvoLog doesn't extend LogstageCodec, and that's why import evo.derivation.logstage.instances.given here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant