This is no tutorial, but it is well commented and easy to understand, it is very basic, I would suggest re-writing the code to fit your needs, especially since this has hardcoded config loading/saving.
This is very simple to recreate, trust me, it took me ~30 mins, the commenting took longer tbh xD
How to use logging:
Logging
Code:
// Include CLogger to your header/cpp where ever you want to log basically.
#include "CLogger.h"
// You must first initalize everything needed to log, only do this once.
std::string logName = cLog->GetCurrentDate(); // This will return a [yyyy-mm-dd - hour-min] string
cLog->SetLogName(logName);
cLog->Open(); // then you must open the file, remember you must set the log name before you open it!
// Then you can start logging messages:
// To actually log a normal message:
cLog->Msg("A log! :)"); // This will log a normal message without any prefix.
// A normal log with %s/i/f ..etc arguments:
cLog->MsgArg("A log with a integer %i", myInt);
// A normal Warning log
cLog->WarnMsg("Warning log!");
// When calling WarnMsg you can also log arguments to your string, by doing the same as MsgArg
cLog->WarnMsg("A log with a integer %i", myInt);
// Its the same for Error logs, you call a error log by
cLog->ErrorMsg("String %s", myString); // Works just as WarnMsg, you can call it without including
// more arguments.
cLog->ErrorMsg("String!");
How to use the config manager:
Configs
Code:
//You must first include CConfig to your cpp/header file to be able to use it.
//To initalize everything you need to do the following
Config->SetName("MyConfig.ini"); // Obviously the .ini can be changed to any file extension you wish.
// To load a config you call (AFter the name has been set!):
Config->LoadConfig();
// To save a config you call (after the name has been set!):
Config->SaveConfig();
// To edit what it saves/loads you must go into CConfig.cpp and go into the LoadConfig/SaveConfig functions
// I recommend you to read up on what you're doing, as this is needed to be hardcoded atm.
// It is as well commented as I could have done.
Example of how a log may look:
How a log may look!
LogName (If you've set it to the current date..):
"[2015-6-15 - 1-24]" the log file does NOT need to have a extension, it is already added by default when initializing everything.