From 725841467fb0f887cf66f074185551d59af239b5 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Sat, 11 Mar 2023 11:23:31 +0300 Subject: [PATCH] Log exceptions with stack traces (#5871) close #5070 Changelog: - Include the original exception to log expressions - Enable logging of Akka Actors' lifecycle events on debug logging level - Decrease the severity of interruption log messages because interruptions are part of the workflow. The computation can be interrupted at any time, and still be recomputed after. Warnings are just misleading in this case. --- .../src/main/resources/application.conf | 1 + .../boot/LanguageServerComponent.scala | 18 +++---- .../enso/languageserver/boot/MainModule.scala | 11 +++-- .../languageserver/boot/TimingsConfig.scala | 2 +- .../boot/resource/RepoInitialization.scala | 22 +++++---- .../org/enso/languageserver/data/Config.scala | 21 +++----- .../filemanager/ContentRoot.scala | 9 +++- .../filemanager/ContentRootManagerActor.scala | 5 +- .../ContentRootManagerWrapper.scala | 1 + .../filemanager/FileSystem.scala | 2 +- .../filemanager/PathWatcher.scala | 4 +- .../io/InputRedirectionController.scala | 2 +- .../libraries/FakeDownload.scala | 48 ------------------- .../libraries/LocalLibraryManager.scala | 12 +++-- .../EditionsGetProjectSettingsHandler.scala | 3 +- .../binary/BinaryConnectionController.scala | 10 ++-- .../json/JsonConnectionController.scala | 2 +- .../runtime/RuntimeConnector.scala | 6 +-- .../runtime/RuntimeFailureMapper.scala | 4 +- .../search/SuggestionsHandler.scala | 34 ++++++------- .../util/UnhandledLogging.scala | 2 +- .../job/ProgramExecutionSupport.scala | 4 +- .../job/UpsertVisualisationJob.scala | 2 +- .../src/main/resources/application.conf | 1 + 24 files changed, 92 insertions(+), 134 deletions(-) delete mode 100644 engine/language-server/src/main/scala/org/enso/languageserver/libraries/FakeDownload.scala diff --git a/engine/language-server/src/main/resources/application.conf b/engine/language-server/src/main/resources/application.conf index 98d24783f512..509a892c0f13 100644 --- a/engine/language-server/src/main/resources/application.conf +++ b/engine/language-server/src/main/resources/application.conf @@ -1,3 +1,4 @@ +akka.actor.debug.lifecycle = on akka.http.server.idle-timeout = infinite akka.http.server.remote-address-header = on akka.http.server.websocket.periodic-keep-alive-max-idle = 1 second diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/boot/LanguageServerComponent.scala b/engine/language-server/src/main/scala/org/enso/languageserver/boot/LanguageServerComponent.scala index 1657003e2a6c..cc8ff37c8894 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/boot/LanguageServerComponent.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/boot/LanguageServerComponent.scala @@ -39,17 +39,17 @@ class LanguageServerComponent(config: LanguageServerConfig, logLevel: LogLevel) override def start(): Future[ComponentStarted.type] = { logger.info("Starting Language Server...") val sampler = startSampling(config) - logger.debug(s"Started ${sampler.getClass.getName}.") + logger.debug("Started [{}].", sampler.getClass.getName) val module = new MainModule(config, logLevel) val bindJsonServer = for { binding <- module.jsonRpcServer.bind(config.interface, config.rpcPort) - _ <- Future { logger.debug("Json RPC server initialized") } + _ <- Future { logger.debug("Json RPC server initialized.") } } yield binding val bindBinaryServer = for { binding <- module.binaryServer.bind(config.interface, config.dataPort) - _ <- Future { logger.debug("Binary server initialized") } + _ <- Future { logger.debug("Binary server initialized.") } } yield binding for { jsonBinding <- bindJsonServer @@ -103,15 +103,15 @@ class LanguageServerComponent(config: LanguageServerConfig, logLevel: LogLevel) private def releaseResources(serverContext: ServerContext): Future[Unit] = for { _ <- Future(serverContext.mainModule.close()).recover(logError) - _ <- Future { logger.info("Terminated main module") } + _ <- Future { logger.info("Terminated main module.") } } yield () private def terminateAkka(serverContext: ServerContext): Future[Unit] = { for { _ <- serverContext.jsonBinding.terminate(2.seconds).recover(logError) - _ <- Future { logger.info("Terminated json connections") } + _ <- Future { logger.info("Terminated json connections.") } _ <- serverContext.binaryBinding.terminate(2.seconds).recover(logError) - _ <- Future { logger.info("Terminated binary connections") } + _ <- Future { logger.info("Terminated binary connections.") } _ <- Await .ready( @@ -119,7 +119,7 @@ class LanguageServerComponent(config: LanguageServerConfig, logLevel: LogLevel) 2.seconds ) .recover(logError) - _ <- Future { logger.info("Terminated actor system") } + _ <- Future { logger.info("Terminated actor system.") } } yield () } @@ -131,7 +131,7 @@ class LanguageServerComponent(config: LanguageServerConfig, logLevel: LogLevel) for { _ <- killFiber.recover(logError) - _ <- Future { logger.info("Terminated truffle context") } + _ <- Future { logger.info("Terminated truffle context.") } } yield () } @@ -143,7 +143,7 @@ class LanguageServerComponent(config: LanguageServerConfig, logLevel: LogLevel) } yield ComponentRestarted private val logError: PartialFunction[Throwable, Unit] = { case th => - logger.error("An error occurred during stopping server", th) + logger.error("An error occurred during stopping the server.", th) } } diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala b/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala index 7ee46863f782..2aa80b761a92 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala @@ -42,7 +42,7 @@ import org.enso.librarymanager.LibraryLocations import org.enso.librarymanager.local.DefaultLocalLibraryProvider import org.enso.librarymanager.published.PublishedLibraryCache import org.enso.lockmanager.server.LockManagerService -import org.enso.logger.masking.Masking +import org.enso.logger.masking.{MaskedPath, Masking} import org.enso.loggingservice.{JavaLoggingLogHandler, LogLevel} import org.enso.polyglot.{HostAccessFactory, RuntimeOptions, RuntimeServerInfo} import org.enso.searcher.sql.{SqlDatabase, SqlSuggestionsRepo, SqlVersionsRepo} @@ -102,7 +102,7 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) { None, Some(serverConfig.computeExecutionContext) ) - log.trace(s"Created ActorSystem $system.") + log.trace("Created ActorSystem [{}].", system) private val zioRuntime = effect.Runtime.fromExecutionContext(system.dispatcher) @@ -165,7 +165,9 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) { monitor case Failure(exception) => log.error( - s"Failed to create runtime events monitor for $path ($exception)." + "Failed to create runtime events monitor for [{}].", + MaskedPath(path), + exception ) new NoopEventsMonitor } @@ -173,7 +175,8 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) { new NoopEventsMonitor } log.trace( - s"Started runtime events monitor ${runtimeEventsMonitor.getClass.getName}." + "Started runtime events monitor [{}].", + runtimeEventsMonitor.getClass.getName ) lazy val runtimeConnector = diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/boot/TimingsConfig.scala b/engine/language-server/src/main/scala/org/enso/languageserver/boot/TimingsConfig.scala index 72b18631fa47..903972af5fc7 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/boot/TimingsConfig.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/boot/TimingsConfig.scala @@ -4,7 +4,7 @@ import scala.concurrent.duration._ /** TimingsConfig encapsulates information about timings or delays in messages being sent between services. * - * @param autoSave a request timeout + * @param timeout a request timeout * @param autoSave if non-empty value, determines the delay when auto-save should be triggered */ class TimingsConfig( diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/boot/resource/RepoInitialization.scala b/engine/language-server/src/main/scala/org/enso/languageserver/boot/resource/RepoInitialization.scala index 47e915257393..5f2a5c551fba 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/boot/resource/RepoInitialization.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/boot/resource/RepoInitialization.scala @@ -62,9 +62,9 @@ class RepoInitialization( eventStream.publish(InitializedEvent.SuggestionsRepoInitialized) case Failure(ex) => logger.error( - "Failed to initialize SQL suggestions repo [{}]. {}", + "Failed to initialize SQL suggestions repo [{}].", MaskedPath(directoriesConfig.suggestionsDatabaseFile.toPath), - ex.getMessage + ex ) } initAction @@ -92,9 +92,9 @@ class RepoInitialization( eventStream.publish(InitializedEvent.VersionsRepoInitialized) case Failure(ex) => logger.error( - "Failed to initialize SQL versions repo [{}]. {}", + "Failed to initialize SQL versions repo [{}].", MaskedPath(directoriesConfig.suggestionsDatabaseFile.toPath), - ex.getMessage + ex ) } initAction @@ -107,9 +107,9 @@ class RepoInitialization( for { _ <- Future { logger.warn( - "Failed to initialize the suggestions database [{}]. {}", + "Failed to initialize the suggestions database [{}].", MaskedPath(directoriesConfig.suggestionsDatabaseFile.toPath), - error.getMessage + error ) } _ <- Future(db.close()) @@ -136,8 +136,10 @@ class RepoInitialization( Future.successful(()) case error: FileSystemException => logger.error( - s"Failed to delete the database file. Attempt #${retries + 1}." + - s"The file will be removed during the shutdown. ${error.getMessage}." + "Failed to delete the database file. Attempt #{}. " + + "The file will be removed during the shutdown.", + retries + 1, + error ) sys.addShutdownHook( FileUtils.deleteQuietly(directoriesConfig.suggestionsDatabaseFile) @@ -145,9 +147,9 @@ class RepoInitialization( Future.failed(error) case error: IOException => logger.error( - "Failed to delete the database file. Attempt #{}. {}", + "Failed to delete the database file. Attempt #{}.", retries + 1, - error.getMessage + error ) if (retries < RepoInitialization.MaxRetries) { Thread.sleep(1000) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/data/Config.scala b/engine/language-server/src/main/scala/org/enso/languageserver/data/Config.scala index ef9a80343cf5..1accf947c3de 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/data/Config.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/data/Config.scala @@ -2,10 +2,11 @@ package org.enso.languageserver.data import org.enso.languageserver.boot.ProfilingConfig import org.enso.languageserver.filemanager.ContentRootWithFile -import org.enso.logger.masking.{MaskingUtils, ToLogString} +import org.enso.logger.masking.{MaskedPath, ToLogString} import java.io.File import java.nio.file.{Files, Path} + import scala.concurrent.duration._ /** Configuration of the path watcher. @@ -105,9 +106,7 @@ case class ProjectDirectoriesConfig(root: File) extends ToLogString { /** @inheritdoc */ override def toLogString(shouldMask: Boolean): String = { - val rootString = - if (shouldMask) MaskingUtils.toMaskedPath(root.toPath) - else root.toString + val rootString = MaskedPath(root.toPath).toLogString(shouldMask) s"DirectoriesConfig($rootString)" } @@ -156,22 +155,16 @@ case class Config( ) extends ToLogString { /** @inheritdoc */ - override def toLogString(shouldMask: Boolean): String = { - val maskedRoot = - if (shouldMask) { - MaskingUtils.toMaskedPath(projectContentRoot.file.toPath) - } else { - projectContentRoot - } + override def toLogString(shouldMask: Boolean): String = s"Config(" + - s"projectContentRoot=$maskedRoot, " + + s"projectContentRoot=${projectContentRoot.toLogString(shouldMask)}, " + s"fileManager=$fileManager, " + s"vcsManager=$vcsManager, " + s"pathWatcher=$pathWatcher, " + s"executionContext=$executionContext, " + s"directories=${directories.toLogString(shouldMask)}" + - s")" - } + ")" + } object Config { def ensoPackageConfigName: String = "package.yaml" diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRoot.scala b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRoot.scala index bca912a8eb8b..ad2b7d13072a 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRoot.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRoot.scala @@ -2,6 +2,7 @@ package org.enso.languageserver.filemanager import io.circe.syntax.EncoderOps import io.circe.{Encoder, Json} +import org.enso.logger.masking.{MaskedPath, ToLogString} import java.io.File import java.util.UUID @@ -115,7 +116,7 @@ object ContentRoot { case class ContentRootWithFile( contentRoot: ContentRoot, file: File -) { +) extends ToLogString { /** The unique identifier of the content root. */ def id: UUID = contentRoot.id @@ -125,4 +126,10 @@ case class ContentRootWithFile( * @return a protocol content root */ def toContentRoot: ContentRoot = contentRoot + + /** @inheritdoc */ + override def toLogString(shouldMask: Boolean): String = + s"ContentRootWithFile(contentRoot=$contentRoot," + + s"file=${MaskedPath(file.toPath).toLogString(shouldMask)}" + + ")" } diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRootManagerActor.scala b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRootManagerActor.scala index bebe51f4be2d..ffc00aff961d 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRootManagerActor.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRootManagerActor.scala @@ -30,6 +30,7 @@ class ContentRootManagerActor(config: Config) extends Actor with LazyLogging with UnhandledLogging { + override def preStart(): Unit = { context.system.eventStream.subscribe(self, classOf[Api.LibraryLoaded]) } @@ -70,8 +71,8 @@ class ContentRootManagerActor(config: Config) ) logger.trace( - s"Library root for [$namespace.$name:$version] added at " + - s"[${MaskedPath(rootPath.toPath).applyMasking()}]." + s"Library root for [$namespace.$name:$version] added at [{}].", + MaskedPath(rootPath.toPath) ) subscribers.foreach { subscriber => diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRootManagerWrapper.scala b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRootManagerWrapper.scala index 94c39b492137..3adbcd2f2fd7 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRootManagerWrapper.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/ContentRootManagerWrapper.scala @@ -17,6 +17,7 @@ class ContentRootManagerWrapper( config: Config, contentRootManagerActor: ActorRef ) extends ContentRootManager { + implicit private val timeout: Timeout = Timeout( 2 * config.executionContext.requestTimeout ) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/FileSystem.scala b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/FileSystem.scala index faafdfeff777..ce4e1d956974 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/FileSystem.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/FileSystem.scala @@ -20,7 +20,7 @@ class FileSystem extends FileSystemApi[BlockingIO] { private val tenMb: Int = 1 * 1024 * 1024 * 10 /** The stride used by the [[FileSystem]] when processing a file in chunks. */ - val fileChunkSize: Int = tenMb + private val fileChunkSize: Int = tenMb import FileSystemApi._ diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/PathWatcher.scala b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/PathWatcher.scala index 59ce34337ba9..7a214efddb0c 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/PathWatcher.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/filemanager/PathWatcher.scala @@ -116,14 +116,14 @@ final class PathWatcher( stopWatcher() restartCounter.inc() if (restartCounter.canRestart) { - logger.error(s"Restart on error#${restartCounter.count}", e) + logger.error("Restart #{} on error.", restartCounter.count, e) context.system.scheduler.scheduleOnce( config.restartTimeout, self, WatchPath(base, clients) ) } else { - logger.error("Hit maximum number of restarts", e) + logger.error("Hit maximum number of restarts.", e) clients.foreach { client => client ! CapabilityForceReleased( CapabilityRegistration(ReceivesTreeUpdates(base)) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/io/InputRedirectionController.scala b/engine/language-server/src/main/scala/org/enso/languageserver/io/InputRedirectionController.scala index 5731f7f4ad20..22d9f56a69bf 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/io/InputRedirectionController.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/io/InputRedirectionController.scala @@ -49,7 +49,7 @@ class InputRedirectionController( private def running(liveContexts: Set[ContextData] = Set.empty): Receive = { case FeedStandardInput(input, isLineTerminated) => - logger.debug("Feeding stdin [{} bytes]", input.length) + logger.debug("Feeding stdin [{} bytes].", input.length) if (isLineTerminated) { val bytes = ByteString.createBuilder diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/FakeDownload.scala b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/FakeDownload.scala deleted file mode 100644 index 49a783845dec..000000000000 --- a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/FakeDownload.scala +++ /dev/null @@ -1,48 +0,0 @@ -package org.enso.languageserver.libraries - -import org.enso.cli.task.{ - ProgressReporter, - ProgressUnit, - TaskProgress, - TaskProgressImplementation -} - -import scala.util.Success - -/** A temporary helper for mocked parts of the API. - * - * It should be removed soon, when the missing parts are implemented. - */ -object FakeDownload { - - /** Creates a [[TaskProgress]] which reports progress updates for a few seconds. - * - * Intended for mocking download-like endpoints. - */ - def make(seconds: Int = 10): TaskProgress[Unit] = { - val tracker = new TaskProgressImplementation[Unit](ProgressUnit.Bytes) - val thread = new Thread(() => { - val n = (seconds * 10).toLong - for (i <- 0L to n) { - tracker.reportProgress(i, Some(n)) - Thread.sleep(100) - } - tracker.setComplete(Success(())) - }) - thread.start() - tracker - } - - /** Simulates a download operation reporting progress updates to the - * [[ProgressReporter]]. - */ - def simulateDownload( - message: String, - progressReporter: ProgressReporter, - seconds: Int = 10 - ): Unit = { - val download = make(seconds = seconds) - progressReporter.trackProgress(message, download) - download.force() - } -} diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LocalLibraryManager.scala b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LocalLibraryManager.scala index ae0ec3c21a87..729929b77d4f 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LocalLibraryManager.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LocalLibraryManager.scala @@ -175,12 +175,13 @@ class LocalLibraryManager( manifestPath = libraryRootPath / LibraryManifest.filename manifest <- loadManifest(manifestPath).recover { error => logger.error( - s"Failed to load the manifest for local library [$libraryName].", + "Failed to load the manifest for local library [{}].", + libraryName, error ) logger.warn( - s"Falling back to an empty manifest for [$libraryName] " + - s"due to loading errors." + "Falling back to an empty manifest for [{}] due to loading errors.", + libraryName ) LibraryManifest.empty @@ -205,8 +206,9 @@ class LocalLibraryManager( config.componentGroups match { case Left(error) => logger.error( - s"Failed to parse library [$libraryName] component groups " + - s"(reason: ${error.message})." + "Failed to parse library [{}] component groups.", + libraryName, + error ) case _ => } diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/handler/EditionsGetProjectSettingsHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/handler/EditionsGetProjectSettingsHandler.scala index c87a3f973d95..87570600b368 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/handler/EditionsGetProjectSettingsHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/handler/EditionsGetProjectSettingsHandler.scala @@ -71,8 +71,7 @@ object EditionsGetProjectSettingsHandler { * [[EditionsGetProjectSettingsHandler]]. * * @param timeout request timeout - * @param projectSettingsManager a reference to the - * [[ProjectSettingsManager]] + * @param projectSettingsManager a reference to the [[ProjectSettingsManager]] */ def props(timeout: FiniteDuration, projectSettingsManager: ActorRef): Props = Props( diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/protocol/binary/BinaryConnectionController.scala b/engine/language-server/src/main/scala/org/enso/languageserver/protocol/binary/BinaryConnectionController.scala index 64faf54c8103..325701b46459 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/protocol/binary/BinaryConnectionController.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/protocol/binary/BinaryConnectionController.scala @@ -130,9 +130,9 @@ class BinaryConnectionController( case ConnectionFailed(th) => logger.error( - "An error occurred during processing web socket connection [{}]. {}", + "An error occurred during processing web socket connection [{}].", clientIp, - th.getMessage + th ) maybeDataSession.foreach(session => context.system.eventStream.publish(BinarySessionTerminated(session)) @@ -160,8 +160,8 @@ class BinaryConnectionController( private def convertVisualisationUpdateToOutPacket( update: VisualisationUpdate ): ByteBuffer = { - implicit val builder = new FlatBufferBuilder(1024) - val event = VisualisationUpdateFactory.create(update) + implicit val builder: FlatBufferBuilder = new FlatBufferBuilder(1024) + val event = VisualisationUpdateFactory.create(update) val msg = OutboundMessageFactory.create( UUID.randomUUID(), None, @@ -177,7 +177,7 @@ class BinaryConnectionController( private def createSessionInitResponsePacket( requestId: EnsoUUID ): ByteBuffer = { - implicit val builder = new FlatBufferBuilder(1024) + implicit val builder: FlatBufferBuilder = new FlatBufferBuilder(1024) val outMsg = OutboundMessageFactory.create( UUID.randomUUID(), Some(requestId), diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/protocol/json/JsonConnectionController.scala b/engine/language-server/src/main/scala/org/enso/languageserver/protocol/json/JsonConnectionController.scala index c81993d18c63..9967c09e213a 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/protocol/json/JsonConnectionController.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/protocol/json/JsonConnectionController.scala @@ -200,7 +200,7 @@ class JsonConnectionController( ) ) case Status.Failure(ex) => - logger.error("Failed to initialize the resources. {}", ex.getMessage) + logger.error("Failed to initialize resources.", ex) receiver ! ResponseError(Some(request.id), ResourcesInitializationError) context.system.eventStream.publish(InitializedEvent.InitializationFailed) context.become(connected(webActor)) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/runtime/RuntimeConnector.scala b/engine/language-server/src/main/scala/org/enso/languageserver/runtime/RuntimeConnector.scala index 4567cd52075c..a6bf2c25d95f 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/runtime/RuntimeConnector.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/runtime/RuntimeConnector.scala @@ -106,9 +106,9 @@ class RuntimeConnector( sender ! msg case None => logger.warn( - s"No sender has been found associated with request id " + - s"[$correlationId], the response " + - s"[${payload.getClass.getCanonicalName}] will be dropped." + "No sender has been found associated with request id [{}], the response [{}] will be dropped.", + correlationId, + payload.getClass.getCanonicalName ) } context.become(initialized(engine, senders - correlationId)) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/runtime/RuntimeFailureMapper.scala b/engine/language-server/src/main/scala/org/enso/languageserver/runtime/RuntimeFailureMapper.scala index b80ba5f6cb33..bd14ba5c703c 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/runtime/RuntimeFailureMapper.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/runtime/RuntimeFailureMapper.scala @@ -123,8 +123,8 @@ final class RuntimeFailureMapper(contentRootManager: ContentRootManager) { case Some(value) => contentRootManager.findRelativePath(value).recoverWith { error => logger.warn( - s"Could not resolve a path within a failure, " + - s"so it will contain none: $error" + "Could not resolve a path within a failure, so it will contain none.", + error ) Future.successful(None) } diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/search/SuggestionsHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/search/SuggestionsHandler.scala index 2677f6e57f09..eee96c578a06 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/search/SuggestionsHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/search/SuggestionsHandler.scala @@ -161,10 +161,9 @@ final class SuggestionsHandler( .fold( t => logger.error( - "Cannot read the package definition from [{}]. {} {}", + "Cannot read the package definition from [{}].", MaskedPath(config.projectContentRoot.file.toPath), - t.getClass.getName, - t.getMessage + t ), pkg => self ! ProjectNameUpdated(pkg.config.name) ) @@ -176,11 +175,7 @@ final class SuggestionsHandler( tryInitialize(init.copy(typeGraph = Some(g))) case Status.Failure(ex) => - logger.error( - "Initialization failure [{}]. {}", - ex.getClass, - ex.getMessage - ) + logger.error("Initialization failure.", ex) case _ => stash() } @@ -228,9 +223,9 @@ final class SuggestionsHandler( } case Failure(ex) => logger.error( - "Error applying suggestion updates for loaded library [{}] ({})", + "Error applying suggestion updates for loaded library [{}].", msg.libraryName, - ex.getMessage + ex ) } @@ -266,10 +261,10 @@ final class SuggestionsHandler( self ! SuggestionsHandler.SuggestionUpdatesCompleted case Failure(ex) => logger.error( - "Error applying suggestion database updates batch of [{}] modules [{}]. ({})", + "Error applying suggestion database updates batch of [{}] modules [{}].", modules.length, modules.mkString(", "), - ex.getMessage + ex ) self ! SuggestionsHandler.SuggestionUpdatesCompleted } @@ -302,10 +297,10 @@ final class SuggestionsHandler( self ! SuggestionsHandler.SuggestionUpdatesCompleted case Failure(ex) => logger.error( - "Error applying suggestion database updates [{}, {}] ({})", + "Error applying suggestion database updates [{}, {}].", msg.module, msg.version, - ex.getMessage + ex ) self ! SuggestionsHandler.SuggestionUpdatesCompleted } @@ -346,9 +341,9 @@ final class SuggestionsHandler( } case Failure(ex) => logger.error( - "Error applying changes from computed values [{}]. {}", + "Error applying changes from computed values [{}].", updates.map(_.expressionId), - ex.getMessage + ex ) } @@ -423,8 +418,8 @@ final class SuggestionsHandler( ) case Failure(ex) => logger.error( - "Error cleaning the index after file delete event. {}", - ex.getMessage + "Error cleaning the index after file delete event.", + ex ) } @@ -579,7 +574,8 @@ final class SuggestionsHandler( ) case action => logger.error( - s"Invalid action during suggestions loading [$action]." + "Invalid action during suggestions loading [{}].", + action ) Seq() } diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/util/UnhandledLogging.scala b/engine/language-server/src/main/scala/org/enso/languageserver/util/UnhandledLogging.scala index ae75d1f369d9..7b6d69535156 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/util/UnhandledLogging.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/util/UnhandledLogging.scala @@ -12,7 +12,7 @@ trait UnhandledLogging extends LazyLogging { this: Actor => override def unhandled(message: Any): Unit = { if (implicitly[Ordering[LogLevel]].lteq(LogLevel.Warning, akkaLogLevel)) { - logger.warn("Received unknown message: {}", message.getClass) + logger.warn("Received unknown message [{}].", message.getClass) } } } diff --git a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala index 43057c5041ef..7f70053d4a67 100644 --- a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala +++ b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala @@ -238,7 +238,7 @@ object ProgramExecutionSupport { val message = error match { case _: ThreadInterruptedException => val message = s"Execution of function $itemName interrupted." - ctx.executionService.getLogger.log(Level.WARNING, message) + ctx.executionService.getLogger.log(Level.FINE, message) message case _ => val message = s"Execution of function $itemName failed ($reason)." @@ -460,7 +460,7 @@ object ProgramExecutionSupport { val result = errorOrVisualisationData match { case Left(_: ThreadInterruptedException) => ctx.executionService.getLogger.log( - Level.WARNING, + Level.FINE, s"Visualisation thread interrupted ${visualisation.expressionId}." ) Completion.Interrupted diff --git a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/UpsertVisualisationJob.scala b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/UpsertVisualisationJob.scala index c11c0ce855b8..83dbe3ad5c6a 100644 --- a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/UpsertVisualisationJob.scala +++ b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/UpsertVisualisationJob.scala @@ -250,7 +250,7 @@ object UpsertVisualisationJob { case _: ThreadInterruptedException if retryCount < MaxEvaluationRetryCount => ctx.executionService.getLogger.log( - Level.WARNING, + Level.FINE, s"Evaluation of visualisation was interrupted. Retrying [${retryCount + 1}]." ) evaluateModuleExpression(module, expression, retryCount + 1) diff --git a/lib/scala/project-manager/src/main/resources/application.conf b/lib/scala/project-manager/src/main/resources/application.conf index fff221881524..99d76690be02 100644 --- a/lib/scala/project-manager/src/main/resources/application.conf +++ b/lib/scala/project-manager/src/main/resources/application.conf @@ -1,3 +1,4 @@ +akka.actor.debug.lifecycle = on akka.http.server.idle-timeout = infinite akka.http.server.remote-address-header = on akka.http.server.websocket.periodic-keep-alive-max-idle = 1 second