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

chore: Format reportError log #110

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions akka-javasdk/src/main/scala/akka/javasdk/impl/SdkRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package akka.javasdk.impl
import java.lang.reflect.Constructor
import java.lang.reflect.InvocationTargetException
import java.lang.reflect.Method
import java.util.Locale
import java.util.concurrent.CompletionStage

import scala.annotation.nowarn
Expand Down Expand Up @@ -95,6 +94,7 @@ import io.opentelemetry.api.trace.Tracer
import io.opentelemetry.context.{ Context => OtelContext }
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.slf4j.event.Level

/**
* INTERNAL API
Expand Down Expand Up @@ -624,12 +624,19 @@ private final class Sdk(
protocolMinorVersion = BuildInfo.protocolMinorVersion)

override def reportError(err: UserFunctionError): Future[Done] = {
val severityString = err.severity.name.take(1) + err.severity.name.drop(1).toLowerCase(Locale.ROOT)
val severityString = err.severity match {
case Level.ERROR => "Error"
case Level.WARN => "Warning"
Copy link
Member Author

Choose a reason for hiding this comment

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

Warn => Warning was the reason I changed this, but seems better to do a full match than the letter conversions

case Level.INFO => "Info"
case Level.DEBUG => "Debug"
case Level.TRACE => "Trace"
case other => other.name()
}
val message = s"$severityString reported from Akka runtime: ${err.code} ${err.message}"
val detail = if (err.detail.isEmpty) Nil else List(err.detail)
val seeDocs = DocLinks.forErrorCode(err.code).map(link => s"See documentation: $link").toList
val messages = message :: detail ::: seeDocs
val logMessage = messages.mkString("\n\n")
val logMessage = messages.mkString("\n")
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this extra newline is helpful. Looks like this:

07:29:10.966 INFO  akka.runtime.VersionCheck - A newer version of the SDK [3.0.2] is available. Your current version is [3.0.1-52-ded12af8-SNAPSHOT].
07:29:10.968 WARN  akka.javasdk.ServiceLog - Warn reported from Akka runtime: AK-00011 A newer version of the SDK [3.0.2] is available. Your current version is [3.0.1-52-ded12af8-SNAPSHOT].

To fix this issue, update the version of akka-javasdk in your Akka service. Then build and deploy a new version of it.
07:29:11.608 INFO  akka.runtime.DiscoveryManager - Building component [counter-command-from-topic]


SdkRunner.userServiceLog.atLevel(err.severity).log(logMessage)

Expand Down
Loading