Skip to content
Sgt. Mahdi edited this page Aug 13, 2024 · 6 revisions

Welcome to the CPP_Logger wiki!

My goal in this project is to make industrial standard Logging system for C++ and also make a fancy features for developers to let them debug their code easier. This project won't be perfect without your help so feel free to contribute in this project 😊❤️.

How to use this library:

make an object for logger class:

because the Logger is a single tone you have to make an instance with Logger::initiLogger()

#include "Logger.h"
int main(){

Logger* log = Logger::initLogger();

}

Logging in the console:

if you want only log data and errors on the console not in a file you can easily do it by Log(LogLevel, "message")

Note

this library has levels {LogLevel::INFO, LogLevel::DEBUG, LogLevel::Warning, LogLevel::ERROR, LogLevel::CRITICAL, LogLevel::FATAL}

#include "Logger.h"

int main(){

Logger* log = Logger::initLogger();

log->Log(LogLevel::ERROR, "This is an error log") 
}

Logging in a file:

the way you can save all of these logs in a file is easy you just have to set setLoggingStatus(true); and info you set it false, file logging will be disabled.

Note

The default name of log file is log.log

int main() {

	Logger* log = Logger::initLogger();

	log->setLoggingStatus(true); 

	log->Log(LogLevel::ERROR, "This is an error log"); 

	log->setLoggingStatus(false);
}

Logging into custom name file:

you can also set your file name by calling setLoggingFilename("name") and pass a string as an argument.

int main() {

	Logger* log = Logger::initLogger();

	log->setLoggingStatus(true);

	log->setLoggingFilename("Logging");

	log->Log(LogLevel::ERROR, "This is an error log");

	log->setLoggingStatus(false);
}
Clone this wiki locally