Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
6a66fd18
Commit
6a66fd18
authored
Oct 28, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): qml logger supports time and color level
parent
99f1a0e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
24 deletions
+57
-24
CMakeLists.txt
tests/CMakeLists.txt
+2
-0
logger.cpp
tests/src/logger.cpp
+46
-0
logger.hpp
tests/src/logger.hpp
+8
-0
main.cpp
tests/src/main.cpp
+1
-24
No files found.
tests/CMakeLists.txt
View file @
6a66fd18
...
...
@@ -35,6 +35,7 @@ set(SOURCES
src/components/settings/AccountSettingsListModel.cpp
src/components/settings/AccountSettingsModel.cpp
src/components/settings/SettingsModel.cpp
src/logger.cpp
src/main.cpp
)
...
...
@@ -48,6 +49,7 @@ set(HEADERS
src/components/settings/AccountSettingsListModel.hpp
src/components/settings/AccountSettingsModel.hpp
src/components/settings/SettingsModel.hpp
src/logger.hpp
)
set
(
QRC_RESOURCES
...
...
tests/src/logger.cpp
0 → 100644
View file @
6a66fd18
#include <QDateTime>
#include "logger.hpp"
#ifdef __linux__
#define RED "\x1B[1;31m"
#define GREEN "\x1B[1;32m"
#define BLUE "\x1B[1;34m"
#define RESET "\x1B[0m"
#else
#define RED ""
#define GREEN ""
#define BLUE ""
#define RESET ""
#endif
// ===================================================================
void
qmlLogger
(
QtMsgType
type
,
const
QMessageLogContext
&
context
,
const
QString
&
msg
)
{
QByteArray
local_msg
=
msg
.
toLocal8Bit
();
QByteArray
date_time
=
QDateTime
::
currentDateTime
()
.
toString
(
"HH:mm:ss"
).
toLocal8Bit
();
switch
(
type
)
{
case
QtDebugMsg
:
fprintf
(
stderr
,
GREEN
"[%s][Debug]"
RESET
"%s:%u: %s
\n
"
,
date_time
.
constData
(),
context
.
file
,
context
.
line
,
local_msg
.
constData
());
break
;
case
QtInfoMsg
:
fprintf
(
stderr
,
BLUE
"[%s][Info]"
RESET
"%s:%u: %s
\n
"
,
date_time
.
constData
(),
context
.
file
,
context
.
line
,
local_msg
.
constData
());
break
;
case
QtWarningMsg
:
fprintf
(
stderr
,
RED
"[%s][Warning]"
RESET
"%s:%u: %s
\n
"
,
date_time
.
constData
(),
context
.
file
,
context
.
line
,
local_msg
.
constData
());
break
;
case
QtCriticalMsg
:
fprintf
(
stderr
,
RED
"[%s][Critical]"
RESET
"%s:%u: %s
\n
"
,
date_time
.
constData
(),
context
.
file
,
context
.
line
,
local_msg
.
constData
());
break
;
case
QtFatalMsg
:
fprintf
(
stderr
,
RED
"[%s][Fatal]"
RESET
"%s:%u: %s
\n
"
,
date_time
.
constData
(),
context
.
file
,
context
.
line
,
local_msg
.
constData
());
abort
();
}
}
tests/src/logger.hpp
0 → 100644
View file @
6a66fd18
#ifndef LOGGER_H_
#define LOGGER_H_
#include <QtGlobal>
void
qmlLogger
(
QtMsgType
type
,
const
QMessageLogContext
&
context
,
const
QString
&
msg
);
#endif // LOGGER_H_
tests/src/main.cpp
View file @
6a66fd18
...
...
@@ -10,30 +10,7 @@
#include "app.hpp"
#include "components/contacts/ContactsListProxyModel.hpp"
#include "components/notification/Notification.hpp"
// ===================================================================
void
qmlLogger
(
QtMsgType
type
,
const
QMessageLogContext
&
context
,
const
QString
&
msg
)
{
QByteArray
localMsg
=
msg
.
toLocal8Bit
();
switch
(
type
)
{
case
QtDebugMsg
:
fprintf
(
stderr
,
"[Debug]%s:%u: %s
\n
"
,
context
.
file
,
context
.
line
,
localMsg
.
constData
());
break
;
case
QtInfoMsg
:
fprintf
(
stderr
,
"[Info]%s:%u: %s
\n
"
,
context
.
file
,
context
.
line
,
localMsg
.
constData
());
break
;
case
QtWarningMsg
:
fprintf
(
stderr
,
"[Warning]%s:%u: %s
\n
"
,
context
.
file
,
context
.
line
,
localMsg
.
constData
());
break
;
case
QtCriticalMsg
:
fprintf
(
stderr
,
"[Critical]%s:%u: %s
\n
"
,
context
.
file
,
context
.
line
,
localMsg
.
constData
());
break
;
case
QtFatalMsg
:
fprintf
(
stderr
,
"[Fatal]%s:%u: %s
\n
"
,
context
.
file
,
context
.
line
,
localMsg
.
constData
());
abort
();
}
}
#include "logger.hpp"
// ===================================================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment