winss
|
The logger template. More...
#include <log.hpp>
Public Member Functions | |
LogTmpl (winss::NotOwningPtr< winss::LogStreamReader > reader, winss::NotOwningPtr< winss::LogStreamWriter > writer, const winss::LogSettings &settings) | |
Log template constructor. More... | |
LogTmpl (const LogTmpl &)=delete | |
No copy. More... | |
LogTmpl (LogTmpl &&)=delete | |
No move. More... | |
int | Start () |
Starts the logging implementation. More... | |
LogTmpl & | operator= (const LogTmpl &)=delete |
No copy. More... | |
LogTmpl & | operator= (LogTmpl &&)=delete |
No move. More... | |
Static Public Attributes | |
static const int | kMutexTaken = 100 |
Log dir in use error. More... | |
static const int | kFatalExitCode = 111 |
Something went wrong. More... | |
static constexpr const char | kCurrentLog [8] = "current" |
Log file. More... | |
static constexpr const char | kArchivePrefix [2] = "@" |
File prefix. More... | |
static constexpr const char | kMutexName [4] = "log" |
Mutex name. More... | |
Protected Member Functions | |
bool | Rotate () const |
Rotates the current log file. More... | |
void | CleanArchives () const |
Deletes old archive files. More... | |
Protected Attributes | |
winss::NotOwningPtr< winss::LogStreamReader > | reader |
Log input. More... | |
winss::NotOwningPtr< winss::LogStreamWriter > | writer |
Log output. More... | |
const winss::LogSettings & | settings |
Logger settings. More... | |
fs::path | current |
Current log file. More... | |
TMutex | mutex |
Log dir global mutex. More... | |
std::regex | pattern |
Log file pattern when rotating files. More... | |
The logger template.
Reads from STDIN and writes to a log file. It will occasionally rotate the log file when it gets too big.
|
inline |
Log template constructor.
reader | The log stream reader. |
writer | The log stream writer. |
settings | The logger settings. |
References winss::LogSettings::log_dir.
|
delete |
No copy.
|
delete |
No move.
|
inlineprotected |
Deletes old archive files.
Search the directory given an archive pattern and delete the archives which exceed the total number of archives defined in the settings.
References winss::LogArchiveFile::file, FILESYSTEM, winss::LogSettings::log_dir, winss::LogSettings::number, and winss::LogArchiveFile::time.
|
delete |
No copy.
|
delete |
No move.
|
inlineprotected |
Rotates the current log file.
Current file is closed and renamed then a new current file is opened.
References winss::LogStreamWriter::Close(), FILESYSTEM, winss::LogSettings::log_dir, and winss::LogStreamWriter::Open().
|
inline |
Starts the logging implementation.
Obtains a log on the log dir, starts reading from the reader and writing to the writer until EOF is reached. When a rotation occurs then clean archives will be invoked.
References winss::LogStreamWriter::Close(), winss::Utils::ConvertToISOString(), winss::LogSettings::file_size, FILESYSTEM, winss::LogStreamReader::GetLine(), winss::LogStreamWriter::GetPos(), winss::LogStreamReader::IsEOF(), winss::LogSettings::log_dir, winss::LogStreamWriter::Open(), winss::LogSettings::timestamp, winss::LogStreamWriter::Write(), and winss::LogStreamWriter::WriteLine().
|
protected |
Current log file.
|
static |
File prefix.
|
static |
Log file.
|
static |
Something went wrong.
|
static |
Mutex name.
|
static |
Log dir in use error.
|
protected |
Log dir global mutex.
|
protected |
Log file pattern when rotating files.
|
protected |
Log input.
|
protected |
Logger settings.
|
protected |
Log output.