Skip to content

Commit 90494c5

Browse files
author
tomasmark79
committed
beautification code
1 parent 5781e90 commit 90494c5

File tree

5 files changed

+17
-31
lines changed

5 files changed

+17
-31
lines changed

src/Logger/ConsoleLogger.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ class ConsoleLogger : public dotnamecpp::logging::ILogger {
4545
ConsoleLogger (ConsoleLogger&& other) noexcept : logFile_ (std::move (other.logFile_)),
4646
addNewLine_ (other.addNewLine_) {
4747
}
48-
49-
ConsoleLogger& operator=(ConsoleLogger&& other) noexcept {
48+
49+
ConsoleLogger& operator= (ConsoleLogger&& other) noexcept {
5050
if (this != &other) {
51-
// Use std::lock to avoid deadlocks
52-
std::lock(logMutex_, other.logMutex_);
53-
std::lock_guard<std::mutex> lock1(logMutex_, std::adopt_lock);
54-
std::lock_guard<std::mutex> lock2(other.logMutex_, std::adopt_lock);
55-
56-
logFile_ = std::move(other.logFile_);
57-
addNewLine_ = other.addNewLine_;
58-
currentLevel_ = other.currentLevel_;
51+
// Use std::lock to avoid deadlocks
52+
std::lock (logMutex_, other.logMutex_);
53+
std::lock_guard<std::mutex> lock1 (logMutex_, std::adopt_lock);
54+
std::lock_guard<std::mutex> lock2 (other.logMutex_, std::adopt_lock);
55+
56+
logFile_ = std::move (other.logFile_);
57+
addNewLine_ = other.addNewLine_;
58+
currentLevel_ = other.currentLevel_;
5959
}
6060
return *this;
61-
}
61+
}
6262

6363
void debug (const std::string& message, const std::string& caller = "") override {
6464
log (dotnamecpp::logging::Level::LOG_DEBUG, message, caller);

src/Logger/LoggerFactory.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55

66
namespace dotnamecpp::logging {
77

8-
enum class LoggerType : uint8_t {
9-
Console,
10-
File,
11-
Null // Pro testy
12-
};
8+
enum class LoggerType : uint8_t { Console, File, Null };
139

1410
struct LoggerConfig {
1511
Level level = Level::LOG_INFO;
@@ -25,7 +21,7 @@ namespace dotnamecpp::logging {
2521

2622
static std::shared_ptr<ILogger> createConsole (const LoggerConfig& config = LoggerConfig{});
2723

28-
static std::shared_ptr<ILogger> createNull (); // Pro unit testy
24+
static std::shared_ptr<ILogger> createNull ();
2925
};
3026

3127
} // namespace dotnamecpp::logging

standalone/src/Main.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,15 @@ namespace AppContext {
1717
int main (int argc, const char* argv[]) {
1818
using namespace dotnamecpp;
1919

20-
// Konfigurace aplikace - C++20 designated initializers
21-
logging::LoggerConfig logConfig {
22-
.level = logging::Level::LOG_INFO,
20+
logging::LoggerConfig logConfig{ .level = logging::Level::LOG_INFO,
2321
.enableFileLogging = false,
2422
.logFilePath = "",
25-
.colorOutput = true
26-
};
23+
.colorOutput = true };
2724

28-
app::StandaloneConfig config {
29-
.appName = AppContext::standaloneName,
25+
app::StandaloneConfig config{ .appName = AppContext::standaloneName,
3026
.assetsPath = AppContext::getAssetsPath (),
3127
.loggerConfig = logConfig,
32-
.omitLibraryLoading = false
33-
};
28+
.omitLibraryLoading = false };
3429

3530
// Vytvoření a spuštění aplikace
3631
app::Standalone app (config);

standalone/src/Standalone.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ namespace dotnamecpp::app {
1414

1515
void Standalone::initializeLogger () {
1616
logger_ = logging::LoggerFactory::create (logging::LoggerType::Console, config_.loggerConfig);
17-
1817
logger_->infoStream () << config_.appName << " logger initialized";
1918
}
2019

@@ -39,11 +38,8 @@ namespace dotnamecpp::app {
3938
return EXIT_FAILURE;
4039
}
4140

42-
// Argument parsing logic zde
4341
logger_->infoStream () << config_.appName << " running...";
4442

45-
// Vaše business logic
46-
4743
return 0;
4844
}
4945

standalone/src/Standalone.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ namespace dotnamecpp::app {
3434

3535
int run (int argc, const char* argv[]);
3636

37-
// Getters pro testování
3837
logging::ILogger& getLogger () {
3938
return *logger_;
4039
}

0 commit comments

Comments
 (0)