added logging module and a sandbox project
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
#ifndef MATADOR_FILE_SINK_HPP
|
||||
#define MATADOR_FILE_SINK_HPP
|
||||
|
||||
#include "matador/logger/basic_file_sink.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace matador::logger {
|
||||
|
||||
/**
|
||||
* @brief A file sink writing the log message to one file
|
||||
*
|
||||
* The log sink writes all log messages to one single
|
||||
* file identified by a given path.
|
||||
*
|
||||
* Note because there is no limit, the file grows infinitely.
|
||||
*/
|
||||
class file_sink final : public basic_file_sink
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a file_sink with the given path.
|
||||
* If the path doesn't exist, it is created.
|
||||
*
|
||||
* @param path The log file to write to
|
||||
*/
|
||||
explicit file_sink(const std::string &path);
|
||||
|
||||
/**
|
||||
* Creates a file_sink with the given path.
|
||||
* If the path doesn't exist, it is created.
|
||||
*
|
||||
* @param path The log file to write to
|
||||
*/
|
||||
explicit file_sink(const char *path);
|
||||
|
||||
/**
|
||||
* Destroys the file_sink
|
||||
*/
|
||||
~file_sink() override;
|
||||
|
||||
/**
|
||||
* Returns the path to the log file.
|
||||
*
|
||||
* @return The path to the log file
|
||||
*/
|
||||
std::string path() const;
|
||||
|
||||
private:
|
||||
std::string path_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Log sink writing to stdout
|
||||
*
|
||||
* This log sink writes all messages to stdout.
|
||||
*/
|
||||
class stdout_sink final : public basic_file_sink
|
||||
{
|
||||
public:
|
||||
stdout_sink();
|
||||
~stdout_sink() override = default;
|
||||
|
||||
/**
|
||||
* Do nothing on close
|
||||
*/
|
||||
void close() override {}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Log sink writing to stderr
|
||||
*
|
||||
* This log sink writes all messages to stderr.
|
||||
*/
|
||||
class stderr_sink final : public basic_file_sink
|
||||
{
|
||||
public:
|
||||
stderr_sink();
|
||||
~stderr_sink() override = default;
|
||||
|
||||
/**
|
||||
* Do nothing on close
|
||||
*/
|
||||
void close() override {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //MATADOR_FILE_SINK_HPP
|
||||
Reference in New Issue
Block a user