Skip to content
Sgt. Mahdi edited this page Aug 20, 2024 · 5 revisions

Welcome to the CPP_Logger wiki!

My goal in this project is to make a industrial standard Logging system for C++ and also make 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 SyncLogging class:

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

SyncLogging logger;

}

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 "SyncLogging.h"

int main(){

SyncLogging logger;

logger.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 setSaveLogFileStatus(true); and to stopping it set the function to false.

Note

The default name of log file is log.log

int main() {

//make an instance
SyncLogging logger;

logger.setSaveLogFileStatus(true); //start logging into the file

logger.Log(LogLevel::ERROR, "This is an error log"); //default filename is Log.log

logger.setSaveLogFileStatus(false); //Stop logging into the file
}

Logging into custom name file:

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

int main() {

//make an instance
SyncLogging logger;

logger.setFileName("Logging"); // add your custom name for log file

logger.setSaveLogFileStatus(true); //start logging into the file

logger.Log(LogLevel::ERROR, "This is an error log");
	
logger.setSaveLogFileStatus(false); //Stop logging into the file
}