Skip to content

LogStage: logMethod support #2266

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

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

Conversation

nikita-ty754
Copy link

@nikita-ty754 nikita-ty754 commented Apr 3, 2025

Fix #2157

@nikita-ty754 nikita-ty754 force-pushed the feature/logstage-log-method branch from fd6fcc2 to e4344a9 Compare April 3, 2025 14:02
Copy link

codecov bot commented Apr 3, 2025

Codecov Report

Attention: Patch coverage is 76.47059% with 12 lines in your changes missing coverage. Please review.

Project coverage is 66.70%. Comparing base (702c932) to head (d128c00).
Report is 8 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2266      +/-   ##
===========================================
+ Coverage    66.63%   66.70%   +0.06%     
===========================================
  Files          594      595       +1     
  Lines        11691    11742      +51     
  Branches      1396     1341      -55     
===========================================
+ Hits          7790     7832      +42     
- Misses        3901     3910       +9     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

logImplicits: Boolean,
qp: c.Expr[QuasiIO[F]],
): c.Expr[F[A]] = {
val (variables, logString) = createVariablesAndLogStringTrees(function, logTypes, logImplicits)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val (variables, logString) = createVariablesAndLogStringTrees(function, logTypes, logImplicits)
logMethodIOF(level, c.Expr[F[A]](q"$qp.maybeSuspend($function)"), logTypes, logImplicits, qp)

Should work, since c.Expr[QuasiIO[F]] is <: c.Expr[QuasiPrimitives[F]]

@@ -14,6 +15,58 @@ trait AbstractMacroLogIO[F[_]] { this: AbstractLogIO[F] =>
transparent inline final def error(inline message: String): F[Unit] = log(Log.Level.Error, message)
transparent inline final def crit(inline message: String): F[Unit] = log(Log.Level.Crit, message)

transparent inline final def logMethod[G[x] >: F[x], A](
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default parameters do work in macros on Scala 3, so overloads may be removed here.

Suggested change
transparent inline final def logMethod[G[x] >: F[x], A](
transparent inline final def logMethod[G[x] >: F[x], A](
inline level: Level,
inline logTypes: Boolean = false,
inline logImplicits: Boolean = false,
)(inline function: => A
)(using qp: QuasiIO[G]
): G[A] = {
${ LogMethodMacro.logMethodIO[A, F, G]('level, 'function, 'this, 'logTypes, 'logImplicits, 'qp) }
}
transparent inline final def logMethodF[G[x] >: F[x], A](
inline level: Level,
inline logTypes: Boolean = false,
inline logImplicits: Boolean = false,
)(inline function: => G[A]
)(using qp: QuasiPrimitives[G]
): G[A] = {
${ LogMethodMacro.logMethodIOF[A, F, G]('level, 'function, 'this, 'logTypes, 'logImplicits, 'qp) }
}

- logMethod test
- use default parameters in scala3 macro
def add(x: Int) ...
def add(x: Int, y: Int) ...
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.

Logstage: macro helper for logging method calls with parameters and returns
2 participants