aboutsummaryrefslogtreecommitdiffstats
path: root/yage/core/logger.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-06-23 15:49:21 +0100
committerYann Herklotz <ymherklotz@gmail.com>2018-06-23 15:49:21 +0100
commit9f92cab6b884711ca8be050b500a2880a955f001 (patch)
treefa0999a72436a81c82c49ba8dc473522ac30ceb6 /yage/core/logger.cpp
parent3702e753a5f7b31c31261c968757e19e808a84ec (diff)
downloadYAGE-9f92cab6b884711ca8be050b500a2880a955f001.tar.gz
YAGE-9f92cab6b884711ca8be050b500a2880a955f001.zip
Switching to east const
This is compared to const west, which is not very consistent, as const always acts on what is on its left, and if there isn't anything on the left, it will act on what is on its right. By always placing const on the right of what it should act on, the rule becomes more consistent.
Diffstat (limited to 'yage/core/logger.cpp')
-rw-r--r--yage/core/logger.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/yage/core/logger.cpp b/yage/core/logger.cpp
index f420502d..261d8bca 100644
--- a/yage/core/logger.cpp
+++ b/yage/core/logger.cpp
@@ -24,7 +24,7 @@ namespace yage
{
LogMessage::LogMessage(Logger *owner, LogLevel level,
- const std::string &file_name, int line_num)
+ std::string const &file_name, int line_num)
: owner_(owner), meta_({level, file_name, line_num})
{
}
@@ -44,11 +44,11 @@ LogMessage &LogMessage::operator<<(std::ostream &(*fn)(std::ostream &os))
return *this;
}
-LogSink::LogSink(const LogSink &sink) : wrapper_(sink.wrapper_->clone()) {}
+LogSink::LogSink(LogSink const &sink) : wrapper_(sink.wrapper_->clone()) {}
LogSink::LogSink(LogSink &&sink) : wrapper_(std::move(sink.wrapper_)) {}
-LogSink &LogSink::operator=(const LogSink &sink)
+LogSink &LogSink::operator=(LogSink const &sink)
{
wrapper_.reset(sink.wrapper_->clone());
return *this;
@@ -60,19 +60,19 @@ LogSink &LogSink::operator=(LogSink &&sink)
return *this;
}
-bool LogSink::operator==(const LogSink &sink)
+bool LogSink::operator==(LogSink const &sink)
{
return (wrapper_.get() == sink.wrapper_.get());
}
-void LogSink::write(const LogMessage::Meta &meta, const std::string &msg) const
+void LogSink::write(LogMessage::Meta const &meta, std::string const &msg) const
{
wrapper_->write(meta, msg);
}
LogSink makeConsoleSink()
{
- return [](const LogMessage::Meta &meta, const std::string &msg) {
+ return [](LogMessage::Meta const &meta, std::string const &msg) {
std::cout << msg << "\n";
};
}
@@ -91,7 +91,7 @@ public:
}
}
- FileSink(const std::string filename)
+ FileSink(std::string const filename)
: fileHandle_(std::make_shared<std::ofstream>(filename))
{
if (!fileHandle_->good()) {
@@ -101,7 +101,7 @@ public:
~FileSink() = default;
- void operator()(const LogMessage::Meta &meta, const std::string &msg) const
+ void operator()(const LogMessage::Meta &meta, std::string const &msg) const
{
using namespace std::chrono;
@@ -148,7 +148,7 @@ private:
} // namespace
-LogSink makeFileSink(const std::string &filename)
+LogSink makeFileSink(std::string const &filename)
{
return FileSink(filename);
}
@@ -163,7 +163,7 @@ Logger::Logger() : active_(Active::create()), min_level_(LogLevel::INFO)
add(makeConsoleSink());
}
-Logger::Logger(const std::string &file_path)
+Logger::Logger(std::string const &file_path)
: active_(Active::create()), min_level_(LogLevel::INFO)
{
add(makeConsoleSink());
@@ -176,14 +176,14 @@ Logger::Logger(LogLevel min_level)
add(makeConsoleSink());
}
-Logger::Logger(LogLevel min_level, const std::string &file_path)
+Logger::Logger(LogLevel min_level, std::string const &file_path)
: active_(Active::create()), min_level_(min_level)
{
add(makeConsoleSink());
add(makeFileSink(file_path));
}
-LogMessage Logger::operator()(LogLevel level, const std::string &fileName,
+LogMessage Logger::operator()(LogLevel level, std::string const &fileName,
int lineNum)
{
return LogMessage(this, level, fileName, lineNum);