Skip to content

Logger: simple, convinient and thread safe logger for Qt-based C++ apps

License

Notifications You must be signed in to change notification settings

valaczka/CuteLogger

 
 

Repository files navigation

CuteLogger

Build Status

Simple, convinient and thread safe logger for Qt-based C++ apps

Features

  • Logs pretty much everything: file name, source line, function signature
  • Flexible appender system: log to file, console or even Android logcat, add custom appenders, customize output format
  • Compatible with Qt builtin types. Can be used as a drop-in replacement for qDebug etc.
  • Supports measuring timing for an operations
  • Supports log categories, able to log all messages from a class/namespace to custom category
  • Thread safe

Documentation

Doxygen docs available

Short example

#include <QCoreApplication>
#include <Logger.h>
#include <ConsoleAppender.h>

int main(int argc, char* argv[])
{
  QCoreApplication app(argc, argv);
  ...
  ConsoleAppender* consoleAppender = new ConsoleAppender;
  consoleAppender->setFormat("[%{type:-7}] <%{Function}> %{message}\n");
  cuteLogger->registerAppender(consoleAppender);
  ...
  LOG_INFO("Starting the application");
  int result = app.exec();
  ...
  if (result)
    LOG_WARNING() << "Something went wrong." << "Result code is" << result;
  return result;
}

Adding CuteLogger to your project

Add this repo as a git submodule to your project.

git submodule add git@github.com:dept2/CuteLogger.git CuteLogger

Include it to your CMakeLists.txt file:

...
ADD_SUBDIRECTORY(Logger)
...
TARGET_LINK_LIBRARIES(${your_target} ... CuteLogger)

Include Logger.h and one or several appenders of your choice:

#include <Logger.h>
#include <ConsoleAppender.h>

About

Logger: simple, convinient and thread safe logger for Qt-based C++ apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 96.8%
  • CMake 1.3%
  • Other 1.9%