Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logstage derivation module #85

Open
wants to merge 5 commits into
base: base
Choose a base branch
from

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.

None yet

1 participant