Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/simple_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ Logger::Logger()
{
}

void Logger::init(std::string filename, Append append)
{
Logger::init(filename, static_cast<bool>(append));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it would be better to use switch statement instead of casting the enum and relying on some specific value.

}

void Logger::init(std::string filename, bool append)
{
Impl::init(filename, append);
Expand Down
12 changes: 12 additions & 0 deletions src/simple_logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class Logger
EpochMicroseconds
};

enum class Append : bool
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better name for this enum could be something like OpenMode and probably with values Create and Append. In my opinion Append::Append looks a bit weird.

{
NoAppend = false,
Append = true
};

//! Constructor.
Logger();

Expand All @@ -78,6 +84,12 @@ class Logger
* Throws on error. */
static void init(std::string filename, bool append = false);

/*! Initialize the logger using an enum type for append mode.
* \param filename Log to filename. Disabled if empty.
* \param append The existing log will be appended if Append.
* Throws on error. */
static void init(std::string filename, Append append);

//! Enable/disable echo mode.
//! \param enable Echo everything if true. Default is false.
static void enableEchoMode(bool enable);
Expand Down