From 0feaa1af8f74d75efd253360f8489d81921eb4d1 Mon Sep 17 00:00:00 2001 From: Siddharth Banga <91724657+VOSID8@users.noreply.github.com> Date: Tue, 2 Apr 2024 03:28:56 +0530 Subject: [PATCH 1/5] Added few error loggers --- .vscode/settings.json | 5 +++++ .../main/scala/scaladex/client/ActiveNavObserver.scala | 10 ++++++++-- project/Docker.scala | 4 +++- project/Elasticsearch.scala | 1 + project/Postgres.scala | 1 + 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..32cfc61d2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.watcherExclude": { + "**/target": true + } +} \ No newline at end of file diff --git a/modules/webclient/src/main/scala/scaladex/client/ActiveNavObserver.scala b/modules/webclient/src/main/scala/scaladex/client/ActiveNavObserver.scala index 4d49fa00c..09e898f5c 100644 --- a/modules/webclient/src/main/scala/scaladex/client/ActiveNavObserver.scala +++ b/modules/webclient/src/main/scala/scaladex/client/ActiveNavObserver.scala @@ -30,8 +30,14 @@ object ActiveNavObserver { // ignore the observed entry and update all sections instead debounceUpdate = timers.setTimeout(150) { for ((section, navItem) <- sectionsAndNavItem) - if (isInViewport(section)) navItem.classList.add("active") - else navItem.classList.remove("active") + if (isInViewport(section)) { + navItem.classList.add("active") + println(s"Section ${section.getAttribute("id")} is in viewport") + } + else { + navItem.classList.remove("active") + println(s"Section ${section.getAttribute("id")} is out of viewport") + } } } diff --git a/project/Docker.scala b/project/Docker.scala index 57dc1e7cd..41e3c71dc 100644 --- a/project/Docker.scala +++ b/project/Docker.scala @@ -10,6 +10,8 @@ object Docker { def kill(containerId: String): Unit = try client.killContainerCmd(containerId).exec() catch { - case _: Throwable => () + case e: Throwable => + // Log the error + println(s"Error killing container $containerId: ${e.getMessage}") } } diff --git a/project/Elasticsearch.scala b/project/Elasticsearch.scala index 51ca9ef76..69efb9db1 100644 --- a/project/Elasticsearch.scala +++ b/project/Elasticsearch.scala @@ -81,6 +81,7 @@ object Elasticsearch extends AutoPlugin { container.getFirstMappedPort() } catch { case e: Throwable => + logger.error("Error starting Elasticsearch container:", e) container.stop() throw e } diff --git a/project/Postgres.scala b/project/Postgres.scala index 54773ee3e..76939ff98 100644 --- a/project/Postgres.scala +++ b/project/Postgres.scala @@ -92,6 +92,7 @@ object Postgres extends AutoPlugin { container.getFirstMappedPort() } catch { case e: Throwable => + logger.error("Error starting PostgreSQL container:", e) container.close() throw e } From 4c39721c16ae36f9c45772527ab1a55880951c16 Mon Sep 17 00:00:00 2001 From: Siddharth Banga <91724657+VOSID8@users.noreply.github.com> Date: Tue, 2 Apr 2024 03:40:29 +0530 Subject: [PATCH 2/5] Added few error loggers --- .gitignore | 1 + project/Elasticsearch.scala | 2 +- project/Postgres.scala | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0d8ac05d2..59e31491c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ scaladex.log .metals/ **/project/metals.sbt .bsp/ +.vscode diff --git a/project/Elasticsearch.scala b/project/Elasticsearch.scala index 69efb9db1..4c9fa775a 100644 --- a/project/Elasticsearch.scala +++ b/project/Elasticsearch.scala @@ -81,7 +81,7 @@ object Elasticsearch extends AutoPlugin { container.getFirstMappedPort() } catch { case e: Throwable => - logger.error("Error starting Elasticsearch container:", e) + logger.error(s"Error starting Elasticsearch container: {$e}") container.stop() throw e } diff --git a/project/Postgres.scala b/project/Postgres.scala index 76939ff98..0ffbc8d0e 100644 --- a/project/Postgres.scala +++ b/project/Postgres.scala @@ -92,7 +92,7 @@ object Postgres extends AutoPlugin { container.getFirstMappedPort() } catch { case e: Throwable => - logger.error("Error starting PostgreSQL container:", e) + logger.error(s"Error starting PostgreSQL container: {$e}") container.close() throw e } From dad031b46eb2c25a0b82a433867119f68b096020 Mon Sep 17 00:00:00 2001 From: Siddharth Banga <91724657+VOSID8@users.noreply.github.com> Date: Tue, 2 Apr 2024 03:53:09 +0530 Subject: [PATCH 3/5] Added few loggers --- .gitignore | 2 +- .../main/scala/scaladex/server/route/ProjectPages.scala | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 59e31491c..bacb55934 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ scaladex.log .metals/ **/project/metals.sbt .bsp/ -.vscode +.vscode/ diff --git a/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala b/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala index 7861b2afc..5fb8c31cf 100644 --- a/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala +++ b/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala @@ -199,7 +199,10 @@ class ProjectPages(env: Env, database: WebDatabase, searchEngine: SearchEngine)( ) Future.successful(redirect(redirectUri, StatusCodes.MovedPermanently)) case Some(project) => f(project) - case None => Future.successful(complete(StatusCodes.NotFound, notfound(env, user))) + case None => { + logger.warn(s"Project $ref not found") + Future.successful(complete(StatusCodes.NotFound, notfound(env, user))) + } } onSuccess(future)(identity) } @@ -248,6 +251,7 @@ class ProjectPages(env: Env, database: WebDatabase, searchEngine: SearchEngine)( private def getProjectPage(ref: Project.Reference, user: Option[UserState]): Route = getProjectOrRedirect(ref, user) { project => + logger.info(s"Accessing project page for: $ref") for { header <- getProjectHeader(project) directDependencies <- @@ -256,6 +260,7 @@ class ProjectPages(env: Env, database: WebDatabase, searchEngine: SearchEngine)( .getOrElse(Future.successful(Seq.empty)) reverseDependencies <- database.getProjectDependents(ref) } yield { + logger.info(s"Successfully retrieved project data for: $ref") val groupedDirectDependencies = directDependencies .groupBy(_.target) .view From 8ebea4d69c1f281e768d45b59243ce1691763f5d Mon Sep 17 00:00:00 2001 From: Siddharth Banga <91724657+VOSID8@users.noreply.github.com> Date: Tue, 2 Apr 2024 03:55:46 +0530 Subject: [PATCH 4/5] Added few loggers --- .vscode/settings.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 32cfc61d2..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files.watcherExclude": { - "**/target": true - } -} \ No newline at end of file From 6f0b5e16e840dab41b54fbeea1f017ec3f4b8222 Mon Sep 17 00:00:00 2001 From: Siddharth Banga <91724657+VOSID8@users.noreply.github.com> Date: Tue, 2 Apr 2024 18:52:26 +0530 Subject: [PATCH 5/5] Added a few loggers --- .../src/main/scala/scaladex/server/route/ProjectPages.scala | 3 +-- .../src/main/scala/scaladex/client/ActiveNavObserver.scala | 3 +-- project/Docker.scala | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala b/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala index 5fb8c31cf..c21a8e861 100644 --- a/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala +++ b/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala @@ -199,10 +199,9 @@ class ProjectPages(env: Env, database: WebDatabase, searchEngine: SearchEngine)( ) Future.successful(redirect(redirectUri, StatusCodes.MovedPermanently)) case Some(project) => f(project) - case None => { + case None => logger.warn(s"Project $ref not found") Future.successful(complete(StatusCodes.NotFound, notfound(env, user))) - } } onSuccess(future)(identity) } diff --git a/modules/webclient/src/main/scala/scaladex/client/ActiveNavObserver.scala b/modules/webclient/src/main/scala/scaladex/client/ActiveNavObserver.scala index 09e898f5c..fd7b1baa3 100644 --- a/modules/webclient/src/main/scala/scaladex/client/ActiveNavObserver.scala +++ b/modules/webclient/src/main/scala/scaladex/client/ActiveNavObserver.scala @@ -33,8 +33,7 @@ object ActiveNavObserver { if (isInViewport(section)) { navItem.classList.add("active") println(s"Section ${section.getAttribute("id")} is in viewport") - } - else { + } else { navItem.classList.remove("active") println(s"Section ${section.getAttribute("id")} is out of viewport") } diff --git a/project/Docker.scala b/project/Docker.scala index 41e3c71dc..5284d57ee 100644 --- a/project/Docker.scala +++ b/project/Docker.scala @@ -10,8 +10,8 @@ object Docker { def kill(containerId: String): Unit = try client.killContainerCmd(containerId).exec() catch { - case e: Throwable => - // Log the error - println(s"Error killing container $containerId: ${e.getMessage}") + case e: Throwable => + // Log the error + println(s"Error killing container $containerId: ${e.getMessage}") } }