A simple Logging Library : MyLoggingLibrary

If have developed a simple logging library for console and file and multiple support of appenders. It’s called MyLoggingLibrary.

I have made it available to github: https://github.com/ChristophePichaud/MyLoggingLibrary

It was a sample for my students but it works and it’s simple to use. There is no configuration file.

// Client.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include "pch.h"

int main()
{
	CAppender appender1("log");
	appender1.SetLevel(Level::Debug);
	appender1.SetAppenderType(AppenderType::Console);

	// Appender 2 de type fichier
	CAppender appender2("log");
	appender2.SetLevel(Level::Info);
	appender2.SetAppenderType(AppenderType::File);

	// Objet de configuration
	CConfiguration config;
	config.AddAppender(appender1);
	config.AddAppender(appender2);

	// Get Logger(s) "log" & use => affichage en console et écriture en fichier
	std::unique_ptr<CLogger> logger = config.GetLogger("log", Level::Debug);
	for (int i = 0; i < 10; i++)
	{
		logger->Debug("Logging a Debug...");
		logger->Warning("Logging a Warning...");
		logger->Error("Logging an Error...");
		logger->Info("Logging an Info...");
	}
}

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: