From 22ebeab1bbaf9872c6dec0dcc1e1e709ad054896 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Thu, 2 Sep 2021 20:43:45 +0200
Subject: [PATCH] LOG: Get ride of the ../ in file with the logs

---
 PreCompiledHeaders.cmake                                | 1 +
 src/Lib/Log.cc                                          | 8 +++++++-
 src/Lib/Log.hh                                          | 1 +
 src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc | 7 +++----
 src/VivyApplication.cc                                  | 2 +-
 5 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/PreCompiledHeaders.cmake b/PreCompiledHeaders.cmake
index f09e72ab..4d9128d5 100644
--- a/PreCompiledHeaders.cmake
+++ b/PreCompiledHeaders.cmake
@@ -24,6 +24,7 @@ set(STL_INC
     <ctype.h>
     <mutex>
     <iomanip>
+    <filesystem>
 )
 
 set(EXT_INC PRIVATE
diff --git a/src/Lib/Log.cc b/src/Lib/Log.cc
index b18598ae..4da5f3b1 100644
--- a/src/Lib/Log.cc
+++ b/src/Lib/Log.cc
@@ -29,6 +29,12 @@ StderrLogSinkDispatcher::trunkFileName(const char *fileName) noexcept
                              fileNameView.data() + fileNameView.size() };
 }
 
+std::string
+StderrLogSinkDispatcher::reduceFileName(const std::string_view fileName) noexcept
+{
+    return std::filesystem::path(fileName).lexically_normal();
+}
+
 StderrLogSinkDispatcher::StderrLogSinkDispatcher() noexcept
     : LogSinkDispatcher(std::string_view{ "stderr" })
 {
@@ -38,7 +44,7 @@ void
 StderrLogSinkDispatcher::handleLogMessage(const std::string_view category,
                                           const LogMessage &msg) noexcept
 {
-    std::cerr << "#(" << trunkFileName(msg.getHeader().fileName) << " +"
+    std::cerr << "#(" << reduceFileName(trunkFileName(msg.getHeader().fileName)) << " +"
               << msg.getHeader().lineNumberInFile << " | "
               << LogLevel::toStdStringView(msg.getHeader().severity) << " -> " << category << ") "
               << msg.getTextBuffer() << '\n';
diff --git a/src/Lib/Log.hh b/src/Lib/Log.hh
index 1aa83afa..31b0ebc8 100644
--- a/src/Lib/Log.hh
+++ b/src/Lib/Log.hh
@@ -115,6 +115,7 @@ class StderrLogSinkDispatcher : public LogSinkDispatcher {
     VIVY_UNMOVABLE_OBJECT(StderrLogSinkDispatcher)
 
     static const std::string_view trunkFileName(const char *) noexcept;
+    static std::string reduceFileName(const std::string_view) noexcept;
 
 public:
     explicit StderrLogSinkDispatcher() noexcept;
diff --git a/src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc b/src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc
index 1a35f0ce..5de28117 100644
--- a/src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc
+++ b/src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc
@@ -7,12 +7,11 @@ ModuleDeclaration::resolvModules(LuaContext *const context) noexcept
 {
     for (const auto &str : importNames) {
         const ModuleDeclaration *const mod = context->getModule(str);
-        if (mod) {
+        if (mod)
             importedModules.emplace_back(mod);
-        } else {
+
+        else
             context->failedWith("Failed to find needed module: " + str);
-            return false;
-        }
     }
     return true;
 }
diff --git a/src/VivyApplication.cc b/src/VivyApplication.cc
index 50b86482..343b2f14 100644
--- a/src/VivyApplication.cc
+++ b/src/VivyApplication.cc
@@ -111,7 +111,7 @@ VivyApplication::getApplicationFont(Font id) const noexcept
     }
 
     // Let the program crash
-    qFatal("UNREACHABLE");
+    logFatal() << "Unreachable";
 }
 
 MainWindow *
-- 
GitLab