Skip to content
MarsTech Logging
C++ C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

MarsTech Logging

MarsTech Logging (MLOGGING) is a C++ project to make logging easier. It defines log macros and logger providers for easier logging and creating loggers.


MLOGGING is header only project/library - there is no static or dynamic library. You can download repository and include header file mlogging.h to your project.



MLOGGING uses SPDLOG as default logger. So, download or clone SPDLOG and set path to the directory where SPDLOG is stored. The last step is to include mlogging.h header file.

If you want to use another logging library, create your own logger providers, change definition of MsvLogger and create your own mlogging.h header file.


It is typedef which defines logger type. It is used in classes, functions etc. as logger type. Default logger is SPDLOG and it is defined as:

typedef spdlog::logger MsvLogger;

Log macros

There are log macros to easy create log message including filename and line number:

  • MSV_LOG_DEBUG(msvLogger, msg, ...)
  • MSV_LOG_INFO(msvLogger, msg, ...)
  • MSV_LOG_WARN(msvLogger, msg, ...)
  • MSV_LOG_ERROR(msvLogger, msg, ...)
  • MSV_LOG_CRITICAL(msvLogger, msg, ...)


#include "mlogging/mlogging.h"

//called in some function or method:

MSV_LOG_INFO(m_spLogger, "message");
//prints: [DATE TIME] [processId] [threadId] [loggerName] [info] message

//for message formatting visit project SPDLOG
MSV_LOG_ERROR(m_spLogger, "message {}", 2);
//prints: [DATE TIME] [processId] [threadId] [loggerName] [error] message 2

Logger providers

Logger provider is object which creates loggers. It is usefull for unit testing because you can inject NULL logger provider which creates only NULL loggers (they throw all log messages away).


#include "mlogging/MsvSpdLogLoggerProvider.h"

class LoggingObject
	LoggingObject(std::shared_ptr<IMsvLoggerProvider> spLoggerProvider)
		if (spLoggerProvider)
			m_spLogger = spLoggerProvider->GetLogger("MyLoggerName");
	std::shared_ptr<MsvLogger> m_spLogger;

Logging object base

There is also implementation of logging object base which implements base operations with loggers. It creates (or assigns) logger in its constructor and it also implements copy constructor and assign operator. Just inherit from it and use m_spLogger member for logging in your child class.


#include "mlogging/MsvLoggingObject.h"

class TestLoggingObject:
	public MsvLoggingObject
	TestLoggingObject(std::shared_ptr<MsvLogger> spLogger):

	TestLoggingObject(std::shared_ptr<IMsvLoggerProvider> spLoggerProvider):
		MsvLoggingObject(spLoggerProvider, "TestLogger")
	//Do not forget to call parents assign operator in your child defined assign operators.
	//Childs default assign operator will use it automatically.
	TestLoggingObject& operator= (const TestLoggingObject& origin)
	//logger is accessible as protected member "m_spLogger" and can be used in log macros

Usage Example

There is also an usage example which uses the most of MarsTech projects and libraries. Its source codes and readme can be found at:

Source Code Documentation

You can find generated source code documentation at


This project is released under GNU General Public License version 3. If you can not or do not want to accept GNU GPLv3 license and you would like to use this project under another license, please contact me on or visit

You can’t perform that action at this time.