Skip to content

Commit 8080fd9

Browse files
committed
udp sample
1 parent b5c3063 commit 8080fd9

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# UdpLoggerDemo
3+
#
4+
5+
QT += core
6+
QT -= gui
7+
8+
CONFIG += c++11 console
9+
CONFIG -= app_bundle
10+
11+
# The following define makes your compiler emit warnings if you use
12+
# any feature of Qt which as been marked deprecated (the exact warnings
13+
# depend on your compiler). Please consult the documentation of the
14+
# deprecated API in order to know how to port your code away from it.
15+
DEFINES += QT_DEPRECATED_WARNINGS
16+
17+
# You can also make your code fail to compile if you use deprecated APIs.
18+
# In order to do so, uncomment the following line.
19+
# You can also select to disable deprecated APIs only up to a certain version of Qt.
20+
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
21+
22+
# Define QSLogLib relative path. You can fix this directory
23+
# QSLOG_PARENTPATH = ../../
24+
# QSLOG_HEADERPATH = ../../QSLogLib/
25+
# QSLOG_SOURCEPATH = ../../QSLogLib/
26+
include(../../QSLogLib/QSLogLib.pri)
27+
28+
SOURCES += main.cpp
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
// main.cpp
3+
4+
#include <QtGlobal>
5+
#include <QCoreApplication>
6+
7+
#include "QSLogLib/SLogLib.h"
8+
#include "QSLogLib/Devices/AbstractLoggingDevice.h"
9+
#include "QSLogLib/Devices/ConsoleLogger.h"
10+
#include "QSLogLib/Devices/FileLogger.h"
11+
#include "QSLogLib/Devices/UdpLogger.h"
12+
#include "QSLogLib/Formatters/AbstractFormatter.h"
13+
#include "QSLogLib/Formatters/DetailedFormatter.h"
14+
#include "QSLogLib/Formatters/ErrorFormatter.h"
15+
#include "QSLogLib/Formatters/InfoFormatter.h"
16+
#include "QSLogLib/Formatters/NullFormatter.h"
17+
18+
int main()
19+
{
20+
// Add these lines at the beginning of your program.
21+
// The devices and formatters are automatically deleted by SLogLib.
22+
using namespace SLogLib;
23+
24+
std::string strDestAddress = "192.168.137.1";
25+
unsigned short destPort = 5000;
26+
addLoggingDevice(new UdpLogger(strDestAddress, destPort, new NullFormatter));
27+
28+
// The following line writes the message to both console and file.
29+
int a = 10;
30+
double b = 15.3;
31+
const char* c = "Success";
32+
SLOGLIB_LOG_MSG_INFO("a = " << a << " b = " << b);
33+
SLOGLIB_LOG_MSG_INFO(c);
34+
35+
return 0;
36+
}

0 commit comments

Comments
 (0)