Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

Commit b39b94f

Browse files
authored
Merge pull request #512 from YIO-Remote/feature/logger-rewrite
Logger rewrite
2 parents 946c897 + e8ba5cb commit b39b94f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1564
-1078
lines changed

.clang-format

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ ColumnLimit: 120
99

1010
AccessModifierOffset: -3
1111
AlignConsecutiveDeclarations: true
12+
13+
AllowShortFunctionsOnASingleLine: Inline
14+

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
- name: Get artifact version
7070
run: |
7171
read -r APP_VERSION < binaries/version.txt
72-
echo "::set-env name=APP_VERSION::$APP_VERSION"
72+
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
7373
7474
- name: Upload build artefacts
7575
uses: actions/upload-artifact@v2
@@ -93,8 +93,8 @@
9393

9494
- name: Get timestamp
9595
run: |
96-
echo "::set-env name=TIMESTAMP::$(date +"%Y%m%d_%H%M%S")"
97-
96+
echo "TIMESTAMP=$(date +"%Y%m%d_%H%M%S")" >> $GITHUB_ENV
97+
9898
- name: Create GitHub development build archives
9999
if: "!contains(github.ref, 'tags/v')"
100100
run: |
@@ -128,4 +128,4 @@
128128
files: |
129129
*.tar
130130
${{ env.HASH_FILENAME }}
131-
131+

.github/workflows/build_desktop.yml

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
APP_PRO: remote.pro
2222
APP_NAME: app
2323
PROJECT_NAME: remote-software
24-
# Build artifact output path. Used to set project specific YIO_BIN env var in 'qt_creator' step.
24+
# Build artifact output path. Used to set project specific YIO_BIN env var.
2525
BIN_OUTPUT_PATH: "binaries"
2626
DEBUG_OUTPUT: "false"
2727

@@ -56,6 +56,7 @@ jobs:
5656
# history required to determine number of commits since last release tag
5757
fetch-depth: 0
5858
path: ${{ env.PROJECT_NAME }}
59+
5960
- name: Fetch all tags to determine version
6061
run: |
6162
cd ${{ env.PROJECT_NAME }}
@@ -66,7 +67,11 @@ jobs:
6667
run: |
6768
YIO_INTG_LIB_VERSION=$(cat "${GITHUB_WORKSPACE}/${{ env.PROJECT_NAME }}/dependencies.cfg" | awk '/^integrations.library:/{print $2}')
6869
echo "Required integrations.library: $YIO_INTG_LIB_VERSION"
69-
echo "::set-env name=YIO_INTG_LIB_VERSION::$YIO_INTG_LIB_VERSION"
70+
echo "YIO_INTG_LIB_VERSION=$YIO_INTG_LIB_VERSION" >> $GITHUB_ENV
71+
72+
- name: Set build output directory
73+
shell: bash
74+
run: echo "YIO_BIN=${GITHUB_WORKSPACE}/${BIN_OUTPUT_PATH}" >> $GITHUB_ENV
7075

7176
- name: Checkout integrations.library
7277
uses: actions/checkout@v2
@@ -80,6 +85,8 @@ jobs:
8085
run: |
8186
sudo apt update
8287
sudo apt install libavahi-client-dev libgl1-mesa-dev g++-8 libstdc++-8-dev
88+
# Qt Creator library path is required for Qt linguist tools. Otherwise we'll get libicui18n.so.56 not found!
89+
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/qtcreator/lib/Qt/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
8390
8491
- name: Download Qt Creator
8592
id: qt_creator
@@ -95,22 +102,13 @@ jobs:
95102
set(qtc_platform "windows_vs2015_64")
96103
elseif ("${{ matrix.config.environment_script }}" MATCHES "vcvars64.bat")
97104
set(qtc_platform "windows_msvc2017_x64")
98-
elseif ("${{ matrix.config.environment_script }}" MATCHES "vcvars32.bat")
99-
set(qtc_platform "windows_msvc2017_x86")
100105
endif()
101106
elseif ("${{ runner.os }}" STREQUAL "Linux")
102107
set(qtc_platform "linux_gcc_64_rhel72")
103108
elseif ("${{ runner.os }}" STREQUAL "macOS")
104109
set(qtc_platform "mac_x64")
105110
endif()
106111
107-
# Set YIO_BIN env var for other steps
108-
message("::set-env name=YIO_BIN::${qtc_output_directory}")
109-
# Qt Creator library path is required for Qt linguist tools. Otherwise we'll get libicui18n.so.56 not found!
110-
if ("${{ runner.os }}" STREQUAL "Linux")
111-
message("::set-env name=LD_LIBRARY_PATH::$ENV{GITHUB_WORKSPACE}/qtcreator/lib/Qt/lib:$ENV{LD_LIBRARY_PATH}")
112-
endif()
113-
114112
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/../downloads" download_dir)
115113
116114
file(MAKE_DIRECTORY ${qtc_output_directory})
@@ -181,9 +179,6 @@ jobs:
181179
if ("${{ matrix.config.environment_script }}" MATCHES "vcvars64.bat")
182180
set(qt_package_name "qt.qt5.${qt_version_dotless}.win64_msvc2017_64")
183181
set(qt_dir_prefix "${qt_version}/msvc2017_64")
184-
elseif ("${{ matrix.config.environment_script }}" MATCHES "vcvars32.bat")
185-
set(qt_package_name "qt.qt5.${qt_version_dotless}.win32_msvc2017")
186-
set(qt_dir_prefix "${qt_version}/msvc2017")
187182
else()
188183
endif()
189184
elseif ("${{ runner.os }}" STREQUAL "Linux")
@@ -223,11 +218,6 @@ jobs:
223218
set(package_suffix ${CMAKE_MATCH_2})
224219
string(REPLACE "-debug-symbols" "" package_suffix "${package_suffix}")
225220
226-
# Workaround for CMake's greedy regex
227-
if ("${{ matrix.config.environment_script }}" MATCHES "vcvars32.bat")
228-
string(REPLACE "X86_64" "X86" package_suffix "${package_suffix}")
229-
endif()
230-
231221
file(MAKE_DIRECTORY qt5)
232222
233223
# Save the path for other steps
@@ -298,7 +288,7 @@ jobs:
298288
- name: Configure
299289
shell: cmake -P {0}
300290
run: |
301-
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
291+
if ("${{ runner.os }}" STREQUAL "Windows")
302292
execute_process(
303293
COMMAND "${{ matrix.config.environment_script }}" && set
304294
OUTPUT_FILE environment_script_output.txt
@@ -307,9 +297,6 @@ jobs:
307297
foreach(line IN LISTS output_lines)
308298
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
309299
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
310-
311-
# Set for other steps
312-
message("::set-env name=${CMAKE_MATCH_1}::${CMAKE_MATCH_2}")
313300
endif()
314301
endforeach()
315302
endif()
@@ -342,6 +329,12 @@ jobs:
342329
shell: cmake -P {0}
343330
run: |
344331
if ("${{ runner.os }}" STREQUAL "Windows")
332+
file(STRINGS environment_script_output.txt output_lines)
333+
foreach(line IN LISTS output_lines)
334+
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
335+
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
336+
endif()
337+
endforeach()
345338
set(ENV{PATH} "${{ steps.qt.outputs.qt_dir }}/bin/;$ENV{PATH}")
346339
else()
347340
set(ENV{PATH} "${{ steps.qt.outputs.qt_dir }}/bin/:$ENV{PATH}")
@@ -371,9 +364,9 @@ jobs:
371364
- name: Set build artifact name
372365
shell: bash
373366
run: |
374-
APP_VERSION=$(cat ${{ env.YIO_BIN }}/version.txt | awk '{print $1}')
367+
APP_VERSION=$(cat "${{ env.YIO_BIN }}/version.txt" | awk '{print $1}')
375368
echo "App version: $APP_VERSION"
376-
echo "::set-env name=ARTIFACT_NAME::${{ env.APP_NAME }}-$APP_VERSION-Qt${{ env.QT_VERSION }}-${{ matrix.config.artifact }}-${{ matrix.config.build }}"
369+
echo "ARTIFACT_NAME=${{ env.APP_NAME }}-$APP_VERSION-Qt${{ env.QT_VERSION }}-${{ matrix.config.artifact }}-${{ matrix.config.build }}" >> $GITHUB_ENV
377370
378371
- uses: actions/upload-artifact@v1
379372
id: upload_artifact

.github/workflows/code_guidelines.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ on:
1313

1414
jobs:
1515
cpplint:
16-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-20.04
1717
steps:
1818
- uses: actions/checkout@v2
19-
- uses: actions/setup-python@v1
19+
- uses: actions/setup-python@v2
20+
with:
21+
python-version: '3.8'
2022
- run: python -m pip install cpplint
21-
- run: sudo update-alternatives --install /usr/bin/python python ${pythonLocation}/bin/python3.8 10
2223
- name: cpplint
2324
shell: python
2425
run: |

components/media_player/sources/utils_mediaplayer.cpp

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@
2222

2323
#include "utils_mediaplayer.h"
2424

25-
#include <QDebug>
26-
#include <QLoggingCategory>
27-
2825
#include "../sources/config.h"
29-
30-
static Q_LOGGING_CATEGORY(CLASS_LC, "mediaplayer utils");
26+
#include "../sources/logging.h"
3127

3228
MediaPlayerUtils::MediaPlayerUtils(QObject *parent) : QObject(parent) {
3329
// ADD IMAGE PROVIDER
@@ -36,7 +32,7 @@ MediaPlayerUtils::MediaPlayerUtils(QObject *parent) : QObject(parent) {
3632
m_imageProviderId = QUuid::createUuid().toString().replace("{", "").replace("}", "");
3733
m_imageProvider = new MediaPlayerUtilsImageProvider();
3834
m_engine->addImageProvider(m_imageProviderId, m_imageProvider);
39-
qCDebug(CLASS_LC()) << this << "Image provider added:" << m_imageProviderId << m_imageProvider;
35+
qCDebug(lcMediaPlayer) << this << "Image provider added:" << m_imageProviderId << m_imageProvider;
4036

4137
m_startTimer = new QTimer(this);
4238
m_startTimer->setSingleShot(true);
@@ -52,31 +48,31 @@ MediaPlayerUtils::MediaPlayerUtils(QObject *parent) : QObject(parent) {
5248
}
5349

5450
MediaPlayerUtils::~MediaPlayerUtils() {
55-
qCDebug(CLASS_LC()) << this << "Destructor called";
51+
qCDebug(lcMediaPlayer) << this << "Destructor called";
5652
m_engine->removeImageProvider(m_imageProviderId);
57-
qCDebug(CLASS_LC()) << this << "Destructor: Image provider removed:" << m_imageProviderId;
53+
qCDebug(lcMediaPlayer) << this << "Destructor: Image provider removed:" << m_imageProviderId;
5854

5955
if (m_worker != nullptr) {
60-
qCDebug(CLASS_LC()) << this << "Destructor: Worker was not null";
56+
qCDebug(lcMediaPlayer) << this << "Destructor: Worker was not null";
6157
m_worker->disconnect();
62-
qCDebug(CLASS_LC()) << this << "Destructor: Signal disconnected from Worker class";
58+
qCDebug(lcMediaPlayer) << this << "Destructor: Signal disconnected from Worker class";
6359
m_worker->deleteLater();
6460
m_worker = nullptr;
65-
qCDebug(CLASS_LC()) << this << "Destructor: Worker deleted";
61+
qCDebug(lcMediaPlayer) << this << "Destructor: Worker deleted";
6662
}
6763

6864
if (m_workerThread != nullptr) {
69-
qCDebug(CLASS_LC()) << this << "Destructor: WorkerThread was not null";
65+
qCDebug(lcMediaPlayer) << this << "Destructor: WorkerThread was not null";
7066
if (m_workerThread->isRunning()) {
71-
qCDebug(CLASS_LC()) << this << "Destructor: WorkerThread is running";
67+
qCDebug(lcMediaPlayer) << this << "Destructor: WorkerThread is running";
7268
m_workerThread->quit();
73-
qCDebug(CLASS_LC()) << this << "Destructor: WorkerThread exit was called";
69+
qCDebug(lcMediaPlayer) << this << "Destructor: WorkerThread exit was called";
7470
m_workerThread->wait();
75-
qCDebug(CLASS_LC()) << this << "Destructor: WorkerThread wait";
71+
qCDebug(lcMediaPlayer) << this << "Destructor: WorkerThread wait";
7672
}
7773
m_workerThread->deleteLater();
7874
m_workerThread = nullptr;
79-
qCDebug(CLASS_LC()) << this << "Destructor: WorkerThread was deleted";
75+
qCDebug(lcMediaPlayer) << this << "Destructor: WorkerThread was deleted";
8076
}
8177

8278
if (m_startTimer->isActive()) {
@@ -89,7 +85,7 @@ MediaPlayerUtils::~MediaPlayerUtils() {
8985
m_imageProvider = nullptr;
9086
m_imageProvider->deleteLater();
9187

92-
qCDebug(CLASS_LC()) << this << "Destructor end";
88+
qCDebug(lcMediaPlayer) << this << "Destructor end";
9389
}
9490

9591
void MediaPlayerUtils::setImageURL(QString url) {
@@ -122,12 +118,12 @@ void MediaPlayerUtils::onProcessingDone(const QColor &pixelColor, const QImage &
122118
m_pixelColor = pixelColor;
123119
emit pixelColorChanged();
124120

125-
qCDebug(CLASS_LC()) << this << "Processing done";
121+
qCDebug(lcMediaPlayer) << this << "Processing done";
126122
}
127123

128124
void MediaPlayerUtils::generateImages(const QString &url) {
129125
if (url != m_prevImageURL) {
130-
qCDebug(CLASS_LC()) << this << "Generate images for" << url;
126+
qCDebug(lcMediaPlayer) << this << "Generate images for" << url;
131127

132128
m_prevImageURL = url;
133129
emit processingStarted();
@@ -141,11 +137,11 @@ MediaPlayerUtilsWorker::MediaPlayerUtilsWorker(QObject *parent) : QObject(parent
141137
}
142138

143139
MediaPlayerUtilsWorker::~MediaPlayerUtilsWorker() {
144-
qCDebug(CLASS_LC()) << this << "Worker destructor";
140+
qCDebug(lcMediaPlayer) << this << "Worker destructor";
145141
if (m_manager != nullptr) {
146142
m_manager->deleteLater();
147143
m_manager = nullptr;
148-
qCDebug(CLASS_LC()) << this << "Worker destructor: Manager deleted.";
144+
qCDebug(lcMediaPlayer) << this << "Worker destructor: Manager deleted.";
149145
}
150146
}
151147

@@ -164,7 +160,7 @@ void MediaPlayerUtilsWorker::generateImagesReply() {
164160
image.fill(Qt::black);
165161

166162
if (!image.load(m_reply, nullptr)) {
167-
qCWarning(CLASS_LC) << "ERROR LOADING IMAGE";
163+
qCWarning(lcMediaPlayer) << "ERROR LOADING IMAGE";
168164
if (m_reply) {
169165
m_reply->deleteLater();
170166
m_reply = nullptr;
@@ -174,7 +170,7 @@ void MediaPlayerUtilsWorker::generateImagesReply() {
174170
////////////////////////////////////////////////////////////////////
175171
/// GET DOMINANT COLOR
176172
////////////////////////////////////////////////////////////////////
177-
qCDebug(CLASS_LC()) << this << "Getting dominant color";
173+
qCDebug(lcMediaPlayer) << this << "Getting dominant color";
178174
QColor pixelColor = dominantColor(image);
179175

180176
// change the brightness of the color if it's too bright
@@ -190,7 +186,7 @@ void MediaPlayerUtilsWorker::generateImagesReply() {
190186
////////////////////////////////////////////////////////////////////
191187
/// CREATE LARGE BACKGROUND IMAGE
192188
////////////////////////////////////////////////////////////////////
193-
qCDebug(CLASS_LC()) << this << "Creating image";
189+
qCDebug(lcMediaPlayer) << this << "Creating image";
194190
// resize image
195191
image.scaledToHeight(280, Qt::SmoothTransformation);
196192

@@ -204,18 +200,18 @@ void MediaPlayerUtilsWorker::generateImagesReply() {
204200
painter.drawImage(image.rect(), noise);
205201
painter.end();
206202

207-
qCDebug(CLASS_LC()) << this << "Creating image DONE";
203+
qCDebug(lcMediaPlayer) << this << "Creating image DONE";
208204

209205
emit processingDone(pixelColor, image);
210206
}
211207
} else {
212-
qCWarning(CLASS_LC) << this << "NETWORK REPLY ERROR" << m_reply->errorString();
208+
qCWarning(lcMediaPlayer) << this << "NETWORK REPLY ERROR" << m_reply->errorString();
213209
emit processingDone(QColor("black"), QImage());
214210
}
215211

216212
m_reply->deleteLater();
217213
m_reply = nullptr;
218-
qCDebug(CLASS_LC()) << this << "Network reply deleted";
214+
qCDebug(lcMediaPlayer) << this << "Network reply deleted";
219215
}
220216
}
221217

remote.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ CONFIG += c++17 disable-desktop
2727
CONFIG += qtquickcompiler
2828

2929
DEFINES += QT_DEPRECATED_WARNINGS
30+
DEFINES += QT_MESSAGELOGCONTEXT
3031

3132
# === Version and build information ===========================================
3233
# If built in Buildroot use custom package version, otherwise Git
@@ -144,6 +145,7 @@ HEADERS += \
144145
sources/jsonfile.h \
145146
sources/launcher.h \
146147
sources/logger.h \
148+
sources/logging.h \
147149
sources/softwareupdate.h \
148150
sources/standbycontrol.h \
149151
sources/translation.h \
@@ -191,6 +193,7 @@ SOURCES += \
191193
sources/hardware/touchdetect.cpp \
192194
sources/integrations/integrations.cpp \
193195
sources/logger.cpp \
196+
sources/logging.cpp \
194197
sources/main.cpp \
195198
sources/jsonfile.cpp \
196199
sources/launcher.cpp \

0 commit comments

Comments
 (0)