Skip to content

Repository files navigation

QSLogLib

Read this in other languages: English, 🇰🇷 한국어

  • QSLogLib is a log library based on SLogLibs.
  • It is ported to Qt with improved devices and function.

Note

  • Cmake is not any more supported.
  • Use Qt. instead of complicated cross-platform code.
  • UDP client logger has been added.
  • Other devices will be added. (RDBMS, NoSQL, Bletooth, Serial, DDS, MQ, etc)

Example

1️⃣ How to setup

  • First, include pri file on your Qt project file(*.pro).
# Define QSLogLib relative path. You can fix this directory# QSLOG_PARENTPATH = ../../# QSLOG_HEADERPATH = ../../QSLogLib/# QSLOG_SOURCEPATH = ../../QSLogLib/include(../../QSLogLib/QSLogLib.pri)

2️⃣ Logging Example for standard output and file

#include<QtGlobal>
#include<QCoreApplication>
#include"QSLogLib/SLogLib.h"
#include"QSLogLib/Devices/AbstractLoggingDevice.h"
#include"QSLogLib/Devices/ConsoleLogger.h"
#include"QSLogLib/Devices/FileLogger.h"
#include"QSLogLib/Devices/UdpLogger.h"
#include"QSLogLib/Formatters/AbstractFormatter.h"
#include"QSLogLib/Formatters/DetailedFormatter.h"
#include"QSLogLib/Formatters/ErrorFormatter.h"
#include"QSLogLib/Formatters/InfoFormatter.h"
#include"QSLogLib/Formatters/NullFormatter.h"intmain(int argc, char *argv[])
{
QCoreApplication mainApp(argc, argv);
usingnamespaceQSLogLib;// add logging device for console and file	addLoggingDevice( newConsoleLogger(new NullFormatter) ); // Console + nullFormataddLoggingDevice( newFileLogger("foo.log", new DetailedFormatter) ); // File + detailedFormat// The following line writes the message to both console and file.int a = 10;
double b = 15.3;
constchar* c = "Success";
SLOGLIB_LOG_MSG_INFO("a = " << a << " b = " << b);
SLOGLIB_LOG_MSG_INFO(c);
return0;
}

3️⃣ Logging Example for udp transmission

intmain(int argc, char *argv[])
{
QCoreApplication mainApp(argc, argv);
usingnamespaceQSLogLib;
std::string strDestAddress = "192.168.137.1";
unsignedshort destPort = 5000;
addLoggingDevice(newUdpLogger(strDestAddress, destPort, new NullFormatter));
// The following line writes the message to UDP packet int a = 10;
double b = 15.3;
constchar* c = "Success";
SLOGLIB_LOG_MSG_INFO("a = " << a << " b = " << b);
SLOGLIB_LOG_MSG_INFO(c);
return0;
}

Test Environment

  • Qt 6.0.0 (MingW, Windows 64bit)
  • Qt 5.10.1 (MingW, Windows 32bit)
  • Qt 5.6.2 (Linux 64bit)

License and Authors

To Do

  • Async. logging with multi-threading processing.

Contact

About

Log library for Qt 5 or 6 (based on SLogLib) 🇰🇷 Qt 5 또는 6 기반 로그 라이브러리

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages