Skip to content

Commit

Permalink
formatting for constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
KjellKod committed Nov 30, 2023
1 parent fe32120 commit d95dd8f
Show file tree
Hide file tree
Showing 18 changed files with 93 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ BraceWrapping:
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializers: AfterColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
Expand Down
4 changes: 2 additions & 2 deletions src/filesink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace g3 {
using namespace internal;

FileSink::FileSink(const std::string& log_prefix, const std::string& log_directory, const std::string& logger_id, size_t write_to_log_every_x_message)
: _log_details_func(&LogMessage::DefaultLogDetailsToString), _log_file_with_path(log_directory), _log_prefix_backup(log_prefix), _outptr(new std::ofstream), _header("\t\tLOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL FILE->FUNCTION:LINE] message\n\n\t\t(uuu*: microseconds fractions of the seconds value)\n\n"), _firstEntry(true), _write_counter(0), _write_to_log_every_x_message(write_to_log_every_x_message) {
FileSink::FileSink(const std::string& log_prefix, const std::string& log_directory, const std::string& logger_id, size_t write_to_log_every_x_message) :
_log_details_func(&LogMessage::DefaultLogDetailsToString), _log_file_with_path(log_directory), _log_prefix_backup(log_prefix), _outptr(new std::ofstream), _header("\t\tLOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL FILE->FUNCTION:LINE] message\n\n\t\t(uuu*: microseconds fractions of the seconds value)\n\n"), _firstEntry(true), _write_counter(0), _write_to_log_every_x_message(write_to_log_every_x_message) {
_log_prefix_backup = prefixSanityFix(log_prefix);
if (!isValidFilename(_log_prefix_backup)) {
std::cerr << "g3log: forced abort due to illegal log prefix [" << log_prefix << "]" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/g3log/active.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ namespace kjellkod {

class Active {
private:
Active()
: done_(false) {} // Construction ONLY through factory createActive();
Active() :
done_(false) {} // Construction ONLY through factory createActive();
Active(const Active&) = delete;
Active& operator=(const Active&) = delete;

Expand Down
16 changes: 8 additions & 8 deletions src/g3log/atomicbool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ namespace g3 {
std::atomic<bool> value_;

public:
atomicbool()
: value_{false} {}
atomicbool(bool value)
: value_{value} {}
atomicbool(const std::atomic<bool>& value)
: value_{value.load(std::memory_order_acquire)} {}
atomicbool(const atomicbool& other)
: value_{other.value_.load(std::memory_order_acquire)} {}
atomicbool() :
value_{false} {}
atomicbool(bool value) :
value_{value} {}
atomicbool(const std::atomic<bool>& value) :
value_{value.load(std::memory_order_acquire)} {}
atomicbool(const atomicbool& other) :
value_{other.value_.load(std::memory_order_acquire)} {}

atomicbool& operator=(const atomicbool& other) {
value_.store(other.value_.load(std::memory_order_acquire), std::memory_order_release);
Expand Down
24 changes: 12 additions & 12 deletions src/g3log/loglevels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ struct LEVELS {
// force internal copy of the const char*. This is a simple safeguard for when g3log is used in a
// "dynamic, runtime loading of shared libraries"

LEVELS(const LEVELS& other)
: value(other.value), text(other.text.c_str()) {}
LEVELS(const LEVELS& other) :
value(other.value), text(other.text.c_str()) {}

LEVELS(int id, const std::string& idtext)
: value(id), text(idtext) {}
LEVELS(int id, const std::string& idtext) :
value(id), text(idtext) {}

bool operator==(const LEVELS& rhs) const {
return (value == rhs.value && text == rhs.text);
Expand Down Expand Up @@ -103,14 +103,14 @@ namespace g3 {
LEVELS level;

// default operator needed for std::map compliance
LoggingLevel()
: status(false), level(INFO){};
LoggingLevel(const LoggingLevel& lvl)
: status(lvl.status), level(lvl.level) {}
LoggingLevel(const LEVELS& lvl)
: status(true), level(lvl){};
LoggingLevel(const LEVELS& lvl, bool enabled)
: status(enabled), level(lvl){};
LoggingLevel() :
status(false), level(INFO){};
LoggingLevel(const LoggingLevel& lvl) :
status(lvl.status), level(lvl.level) {}
LoggingLevel(const LEVELS& lvl) :
status(true), level(lvl){};
LoggingLevel(const LEVELS& lvl, bool enabled) :
status(enabled), level(lvl){};
~LoggingLevel() = default;

LoggingLevel& operator=(const LoggingLevel& other) {
Expand Down
12 changes: 6 additions & 6 deletions src/g3log/moveoncopy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ namespace g3 {
struct MoveOnCopy {
mutable Moveable _move_only;

explicit MoveOnCopy(Moveable&& m)
: _move_only(std::move(m)) {}
MoveOnCopy(MoveOnCopy const& t)
: _move_only(std::move(t._move_only)) {}
MoveOnCopy(MoveOnCopy&& t)
: _move_only(std::move(t._move_only)) {}
explicit MoveOnCopy(Moveable&& m) :
_move_only(std::move(m)) {}
MoveOnCopy(MoveOnCopy const& t) :
_move_only(std::move(t._move_only)) {}
MoveOnCopy(MoveOnCopy&& t) :
_move_only(std::move(t._move_only)) {}

MoveOnCopy& operator=(MoveOnCopy const& other) {
_move_only = std::move(other._move_only);
Expand Down
18 changes: 9 additions & 9 deletions src/g3log/sink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ namespace g3 {
AsyncMessageCall _default_log_call;

template <typename DefaultLogCall>
Sink(std::unique_ptr<T> sink, DefaultLogCall call)
: SinkWrapper(),
_real_sink{std::move(sink)},
_bg(kjellkod::Active::createActive()),
_default_log_call(std::bind(call, _real_sink.get(), std::placeholders::_1)) {
Sink(std::unique_ptr<T> sink, DefaultLogCall call) :
SinkWrapper(),
_real_sink{std::move(sink)},
_bg(kjellkod::Active::createActive()),
_default_log_call(std::bind(call, _real_sink.get(), std::placeholders::_1)) {
}

Sink(std::unique_ptr<T> sink, void (T::*Call)(std::string))
: SinkWrapper(),
_real_sink{std::move(sink)},
_bg(kjellkod::Active::createActive()) {
Sink(std::unique_ptr<T> sink, void (T::*Call)(std::string)) :
SinkWrapper(),
_real_sink{std::move(sink)},
_bg(kjellkod::Active::createActive()) {
std::function<void(std::string)> adapter = std::bind(Call, _real_sink.get(), std::placeholders::_1);
_default_log_call = [=](LogMessageMover m) {
adapter(m.get().toString());
Expand Down
4 changes: 2 additions & 2 deletions src/g3log/sinkhandle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace g3 {
std::weak_ptr<internal::Sink<T>> _sink;

public:
SinkHandle(std::shared_ptr<internal::Sink<T>> sink)
: _sink(sink) {}
SinkHandle(std::shared_ptr<internal::Sink<T>> sink) :
_sink(sink) {}

~SinkHandle() = default;

Expand Down
10 changes: 5 additions & 5 deletions src/g3log/stlpatch_future.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ namespace std {
}

template <class _Fty2>
explicit packaged_task(_Fty2&& _Fnarg)
: _my_func(_Fnarg) {
explicit packaged_task(_Fty2&& _Fnarg) :
_my_func(_Fnarg) {
}

packaged_task(packaged_task&& _Other)
: _my_promise(move(_Other._my_promise)),
_my_func(move(_Other._my_func)) {
packaged_task(packaged_task&& _Other) :
_my_promise(move(_Other._my_promise)),
_my_func(move(_Other._my_func)) {
}

packaged_task& operator=(packaged_task&& _Other) {
Expand Down
8 changes: 4 additions & 4 deletions src/logcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ LogCapture::~LogCapture() noexcept(false) {
}

/// Called from crash handler when a fatal signal has occurred (SIGSEGV etc)
LogCapture::LogCapture(const LEVELS& level, g3::SignalType fatal_signal, const char* dump)
: LogCapture("", 0, "", level, "", fatal_signal, dump) {
LogCapture::LogCapture(const LEVELS& level, g3::SignalType fatal_signal, const char* dump) :
LogCapture("", 0, "", level, "", fatal_signal, dump) {
}

/**
Expand All @@ -58,8 +58,8 @@ LogCapture::LogCapture(const LEVELS& level, g3::SignalType fatal_signal, const c
* @fatal_signal for failed CHECK:SIGABRT or fatal signal caught in the signal handler
*/
LogCapture::LogCapture(const char* file, const int line, const char* function, const LEVELS& level,
const char* expression, g3::SignalType fatal_signal, const char* dump)
: _file(file), _line(line), _function(function), _level(level), _expression(expression), _fatal_signal(fatal_signal) {
const char* expression, g3::SignalType fatal_signal, const char* dump) :
_file(file), _line(line), _function(function), _level(level), _expression(expression), _fatal_signal(fatal_signal) {

if (g3::internal::wasFatal(level)) {
_stack_trace = std::string{"\n*******\tSTACKDUMP *******\n"};
Expand Down
42 changes: 21 additions & 21 deletions src/logmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,33 @@ namespace g3 {
}

LogMessage::LogMessage(std::string file, const int line,
std::string function, const LEVELS level)
: _logDetailsToStringFunc(LogMessage::DefaultLogDetailsToString), _timestamp(std::chrono::high_resolution_clock::now()), _call_thread_id(std::this_thread::get_id())
std::string function, const LEVELS level) :
_logDetailsToStringFunc(LogMessage::DefaultLogDetailsToString), _timestamp(std::chrono::high_resolution_clock::now()), _call_thread_id(std::this_thread::get_id())
#if defined(G3_LOG_FULL_FILENAME)
,
_file(file)
,
_file(file)
#else
,
_file(LogMessage::splitFileName(file))
,
_file(LogMessage::splitFileName(file))
#endif
,
_file_path(file),
_line(line),
_function(std::move(function)),
_level(level) {
,
_file_path(file),
_line(line),
_function(std::move(function)),
_level(level) {
}

LogMessage::LogMessage(const std::string& fatalOsSignalCrashMessage)
: LogMessage({""}, 0, {""}, internal::FATAL_SIGNAL) {
LogMessage::LogMessage(const std::string& fatalOsSignalCrashMessage) :
LogMessage({""}, 0, {""}, internal::FATAL_SIGNAL) {
_message.append(fatalOsSignalCrashMessage);
}

LogMessage::LogMessage(const LogMessage& other)
: _logDetailsToStringFunc(other._logDetailsToStringFunc), _timestamp(other._timestamp), _call_thread_id(other._call_thread_id), _file(other._file), _file_path(other._file_path), _line(other._line), _function(other._function), _level(other._level), _expression(other._expression), _message(other._message) {
LogMessage::LogMessage(const LogMessage& other) :
_logDetailsToStringFunc(other._logDetailsToStringFunc), _timestamp(other._timestamp), _call_thread_id(other._call_thread_id), _file(other._file), _file_path(other._file_path), _line(other._line), _function(other._function), _level(other._level), _expression(other._expression), _message(other._message) {
}

LogMessage::LogMessage(LogMessage&& other)
: _logDetailsToStringFunc(other._logDetailsToStringFunc), _timestamp(other._timestamp), _call_thread_id(other._call_thread_id), _file(std::move(other._file)), _file_path(std::move(other._file_path)), _line(other._line), _function(std::move(other._function)), _level(other._level), _expression(std::move(other._expression)), _message(std::move(other._message)) {
LogMessage::LogMessage(LogMessage&& other) :
_logDetailsToStringFunc(other._logDetailsToStringFunc), _timestamp(other._timestamp), _call_thread_id(other._call_thread_id), _file(std::move(other._file)), _file_path(std::move(other._file_path)), _line(other._line), _function(std::move(other._function)), _level(other._level), _expression(std::move(other._expression)), _message(std::move(other._message)) {
}

std::string LogMessage::threadID() const {
Expand All @@ -154,11 +154,11 @@ namespace g3 {
return oss.str();
}

FatalMessage::FatalMessage(const LogMessage& details, g3::SignalType signal_id)
: LogMessage(details), _signal_id(signal_id) {}
FatalMessage::FatalMessage(const LogMessage& details, g3::SignalType signal_id) :
LogMessage(details), _signal_id(signal_id) {}

FatalMessage::FatalMessage(const FatalMessage& other)
: LogMessage(other), _signal_id(other._signal_id) {}
FatalMessage::FatalMessage(const FatalMessage& other) :
LogMessage(other), _signal_id(other._signal_id) {}

LogMessage FatalMessage::copyToLogMessage() const {
return LogMessage(*this);
Expand Down
4 changes: 2 additions & 2 deletions src/logworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

namespace g3 {

LogWorkerImpl::LogWorkerImpl()
: _bg(kjellkod::Active::createActive()) {}
LogWorkerImpl::LogWorkerImpl() :
_bg(kjellkod::Active::createActive()) {}

void LogWorkerImpl::bgSave(g3::LogMessagePtr msgPtr) {
std::unique_ptr<LogMessage> uniqueMsg(std::move(msgPtr.get()));
Expand Down
10 changes: 5 additions & 5 deletions test_unit/test_concept_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class CoutSink {
stringstream buffer;
unique_ptr<ScopedOut> scope_ptr;

CoutSink()
: scope_ptr(std::make_unique<ScopedOut>(std::cout, &buffer)) {}
CoutSink() :
scope_ptr(std::make_unique<ScopedOut>(std::cout, &buffer)) {}

public:
void clear() { buffer.str(""); }
Expand Down Expand Up @@ -67,9 +67,9 @@ namespace g3 {
}

public:
Worker()
: _bg{
kjellkod::Active::createActive()} {
Worker() :
_bg{
kjellkod::Active::createActive()} {
}

~Worker() {
Expand Down
4 changes: 2 additions & 2 deletions test_unit/test_cpp_future_concepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ TEST(Configuration, FutureSilly) {

struct MsgType {
std::string msg_;
MsgType(std::string m)
: msg_(m){};
MsgType(std::string m) :
msg_(m){};
std::string msg() { return msg_; }
};

Expand Down
4 changes: 2 additions & 2 deletions test_unit/test_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@ TEST(CHECK, CHECK_runtimeError) {
const int size_;

public:
explicit dynamic_int_array(int size)
: data_{std::make_unique<int[]>(size)}, size_(size) {}
explicit dynamic_int_array(int size) :
data_{std::make_unique<int[]>(size)}, size_(size) {}

int& at(int i) {
CHECK(i < size_);
Expand Down
4 changes: 2 additions & 2 deletions test_unit/test_linux_dynamic_loaded_sharedlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

struct LogMessageCounter {
std::vector<std::string>& bank;
LogMessageCounter(std::vector<std::string>& storeMessages)
: bank(storeMessages) {
LogMessageCounter(std::vector<std::string>& storeMessages) :
bank(storeMessages) {
}

void countMessages(std::string msg) {
Expand Down
8 changes: 4 additions & 4 deletions test_unit/test_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ TEST(ConceptSink, OneHundredRemoveAllSinks) {

struct VoidReceiver {
std::atomic<int>* _atomicCounter;
explicit VoidReceiver(std::atomic<int>* counter)
: _atomicCounter(counter) {}
explicit VoidReceiver(std::atomic<int>* counter) :
_atomicCounter(counter) {}

void receiveMsg(std::string msg) { /*ignored*/
}
Expand Down Expand Up @@ -271,8 +271,8 @@ TEST(ConceptSink, VoidCall__TwoCalls_ExpectingTwoAdd) {

struct IntReceiver {
std::atomic<int>* _atomicCounter;
explicit IntReceiver(std::atomic<int>* counter)
: _atomicCounter(counter) {}
explicit IntReceiver(std::atomic<int>* counter) :
_atomicCounter(counter) {}

void receiveMsgDoNothing(std::string msg) { /*ignored*/
}
Expand Down
8 changes: 4 additions & 4 deletions test_unit/testing_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ namespace testing_helpers {
}
}

ScopedLogger::ScopedLogger()
: _currentWorker(g3::LogWorker::createLogWorker()) {}
ScopedLogger::ScopedLogger() :
_currentWorker(g3::LogWorker::createLogWorker()) {}
ScopedLogger::~ScopedLogger() {}

g3::LogWorker* ScopedLogger::get() {
return _currentWorker.get();
}

RestoreFileLogger::RestoreFileLogger(std::string directory)
: _scope(new ScopedLogger), _handle(_scope->get()->addSink(std::make_unique<g3::FileSink>("UNIT_TEST_LOGGER", directory, "g3log", kFlushToDiskWithThisInterval), &g3::FileSink::fileWrite)) {
RestoreFileLogger::RestoreFileLogger(std::string directory) :
_scope(new ScopedLogger), _handle(_scope->get()->addSink(std::make_unique<g3::FileSink>("UNIT_TEST_LOGGER", directory, "g3log", kFlushToDiskWithThisInterval), &g3::FileSink::fileWrite)) {
using namespace g3;
g3::initializeLogging(_scope->_currentWorker.get());
clearMockFatal();
Expand Down

0 comments on commit d95dd8f

Please sign in to comment.