Skip to content

Latest commit

 

History

History
37 lines (32 loc) · 1.63 KB

README.md

File metadata and controls

37 lines (32 loc) · 1.63 KB

tlog

header only C++ logging library

Usage

1-Set output stream :

for stream to file
Logger<wchar_t>::log_output_set(L"log/log.txt");
for stream to console no need to call log_output_set function. Stream to console as default.

2-Set priority level

void log_priority_set(LogPriority t_logPriority);
log_priority_set : Logger severity upper limit. All log messages have its own severity and if it is higher than the limit those messages are dropped.
Logger<wchar_t>::log_priority_set(LogPriority::Debug);

3-Create instance

Create an singleton instance,, which ensures that only one object of its kind exists and provides a single point
auto log = Logger<char>::get_instance();

Set format (Optional)

Formatters specify the layout of log records in the final output.
log->formatter_set("%m %t");
%m : message , %t : time
`

Set limit size of file (Optional)

The File size limit property of the File field enables you to set size limits on the file, in byte.
log->file_limit_set(100);

4-Log

Logs a message with log priority level. The other arguments are interpreted as variadic arguments.
log->log(LogPriority::Error, "Lorem ipsum", "tellus felis condimentum odio, : "

Basic Sample

Logger<char>::log_output_set("log/log.txt");
Logger<char>::log_priority_set(LogPriority::Debug);
auto log = Logger<char>::get_instance();
log->file_limit_set(100);
log->formatter_set("%t %m");
log->log(LogPriority::Error, __LINE__, __FILE__, "tellus felis condimentum odio, : " );