-
Notifications
You must be signed in to change notification settings - Fork 80
SAM Type Interface #920
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
base: main
Are you sure you want to change the base?
SAM Type Interface #920
Conversation
core/shared/src/main/scala/org/typelevel/log4cats/JsonLike.scala
Outdated
Show resolved
Hide resolved
| final case class KernelLogLevel(name: String, value: Double) { | ||
| def namePadded: String = KernelLogLevel.padded(this) | ||
|
|
||
| KernelLogLevel.add(this) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (structure): I'm sick right now, but we should get on a call towards the end of next week and go over bincompat.
Case classes are wonderful for applications, but we're going to tend to avoid them because they don't play nicely with bincompat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed 💯
core/shared/src/main/scala/org/typelevel/log4cats/KernelLogLevel.scala
Outdated
Show resolved
Hide resolved
core/shared/src/main/scala/org/typelevel/log4cats/KernelLogLevel.scala
Outdated
Show resolved
Hide resolved
core/shared/src/main/scala/org/typelevel/log4cats/KernelLogLevel.scala
Outdated
Show resolved
Hide resolved
| final def logTrace(record: Log.Builder => Log.Builder): F[Unit] = | ||
| log(KernelLogLevel.Trace, record) | ||
| final def logDebug(record: Log.Builder => Log.Builder): F[Unit] = | ||
| log(KernelLogLevel.Debug, record) | ||
| final def logInfo(record: Log.Builder => Log.Builder): F[Unit] = | ||
| log(KernelLogLevel.Info, record) | ||
| final def logWarn(record: Log.Builder => Log.Builder): F[Unit] = | ||
| log(KernelLogLevel.Warn, record) | ||
| final def logError(record: Log.Builder => Log.Builder): F[Unit] = | ||
| log(KernelLogLevel.Error, record) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (naming): If we do end up needing these, we should simplify down the names
| final def logTrace(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Trace, record) | |
| final def logDebug(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Debug, record) | |
| final def logInfo(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Info, record) | |
| final def logWarn(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Warn, record) | |
| final def logError(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Error, record) | |
| final def trace(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Trace, record) | |
| final def debug(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Debug, record) | |
| final def info(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Info, record) | |
| final def warn(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Warn, record) | |
| final def error(record: Log.Builder => Log.Builder): F[Unit] = | |
| log(KernelLogLevel.Error, record) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets keep it until final change, I tried to change as suggested but its giving error due to duplicates
js-console/src/main/scala/org/typelevel/log4cats/console/ConsoleLogger.scala
Outdated
Show resolved
Hide resolved
|
Thank you for all the suggestions, I will rework on it |
core/shared/src/main/scala/org/typelevel/log4cats/KernelLogLevel.scala
Outdated
Show resolved
Hide resolved
| // All of these should be no-ops and not throw | ||
| logger.info("This should not appear").void *> | ||
| logger.error("This should not appear").void *> | ||
| logger.warn("This should not appear").void *> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup: logger.warn and friends already return F[Unit], so you don't need to add .void
| import cats.effect.IO | ||
| import munit.CatsEffectSuite | ||
|
|
||
| class SamLoggerTest extends CatsEffectSuite { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: tests that require you to inspect the console to see if they pass or not aren't automated tests.
They can be useful when doing exploratory programming, but they shouldn't generally be committed to source.
| test("SamStructuredLogger should handle context with multiple entries") { | ||
| var capturedLogs: List[(KernelLogLevel, Log.Builder[String] => Log.Builder[String])] = Nil | ||
|
|
||
| val testKernel = new LoggerKernel[IO, String] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Instead of inlining this with a var, it'd be better to rework the existing test loggers to use LoggerKernel
…khande/log4cats into feature/log4cats-sam-type
|
@morgen-peschke just a gentle reminder regarding the PR review whenever you get a chance. I understand things can get busy thank you for your time and help! |
| // Removed implicit conversions for monad transformers from Logger - these were intentionally removed | ||
| ProblemFilters | ||
| .exclude[DirectMissingMethodProblem]("org.typelevel.log4cats.Logger.kleisliLogger"), | ||
| ProblemFilters | ||
| .exclude[DirectMissingMethodProblem]("org.typelevel.log4cats.Logger.eitherTLogger"), | ||
| ProblemFilters | ||
| .exclude[DirectMissingMethodProblem]("org.typelevel.log4cats.Logger.optionTLogger"), | ||
| // Removed implicit conversions for monad transformers from LoggerFactory - these were intentionally removed | ||
| ProblemFilters | ||
| .exclude[DirectMissingMethodProblem]("org.typelevel.log4cats.LoggerFactory.kleisliFactory"), | ||
| ProblemFilters | ||
| .exclude[DirectMissingMethodProblem]("org.typelevel.log4cats.LoggerFactory.eitherTFactory"), | ||
| ProblemFilters | ||
| .exclude[DirectMissingMethodProblem]("org.typelevel.log4cats.LoggerFactory.optionTFactory"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally removed or not, filtering them out doesn't fix the bin-compat issues, so we should restore these methods.
| // Added new kernel methods - these are new API additions | ||
| ProblemFilters.exclude[ReversedMissingMethodProblem]("org.typelevel.log4cats.Logger.kernel"), | ||
| ProblemFilters.exclude[ReversedMissingMethodProblem]( | ||
| "org.typelevel.log4cats.extras.DeferredLogger.kernel" | ||
| ), | ||
| ProblemFilters.exclude[ReversedMissingMethodProblem]( | ||
| "org.typelevel.log4cats.extras.DeferredSelfAwareStructuredLogger.kernel" | ||
| ), | ||
| ProblemFilters.exclude[ReversedMissingMethodProblem]( | ||
| "org.typelevel.log4cats.extras.DeferredStructuredLogger.kernel" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumping tlBaseVersion will tell MiMa that you're going to do a minor version bump, and these will go away.
ThisBuild / tlBaseVersion := "2.8"
This PR's objective is to create a SAM type interface in log4cats