Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
captainwong
jlib
Commits
6d62c4de
Commit
6d62c4de
authored
Sep 10, 2018
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update qt log
parent
e01f174b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
log2.h
jlib/log2.h
+3
-1
QtGlobal.h
jlib/qt/QtGlobal.h
+40
-1
No files found.
jlib/log2.h
View file @
6d62c4de
...
@@ -28,6 +28,8 @@ public:
...
@@ -28,6 +28,8 @@ public:
#else // JLIB_DISABLE_LOG
#else // JLIB_DISABLE_LOG
#define JLIB_LOG2_ENABLED
#include <iostream>
#include <iostream>
#include "3rdparty/spdlog/spdlog.h"
#include "3rdparty/spdlog/spdlog.h"
...
@@ -43,7 +45,7 @@ public:
...
@@ -43,7 +45,7 @@ public:
namespace
jlib
{
namespace
jlib
{
static
const
char
g_logger_name
[]
=
"jlogger"
;
static
const
expr
char
g_logger_name
[]
=
"jlogger"
;
inline
void
init_logger
(
const
std
::
wstring
&
file_name
=
L""
)
inline
void
init_logger
(
const
std
::
wstring
&
file_name
=
L""
)
{
{
...
...
jlib/qt/QtGlobal.h
View file @
6d62c4de
...
@@ -11,3 +11,42 @@
...
@@ -11,3 +11,42 @@
#define MYQDEBUG qDebug() << QDEBUG_FILE_LINE_STREAM
#define MYQDEBUG qDebug() << QDEBUG_FILE_LINE_STREAM
#define MYQWARN qWarning() << QDEBUG_FILE_LINE_STREAM
#define MYQWARN qWarning() << QDEBUG_FILE_LINE_STREAM
#define MYQCRITICAL qCritical() << QDEBUG_FILE_LINE_STREAM
#define MYQCRITICAL qCritical() << QDEBUG_FILE_LINE_STREAM
// if not defined, disable redirect
// if defined, you must include log2.h before include this file
#define REDIRECT_QT_OUTPUT_TO_LOG
#ifdef REDIRECT_QT_OUTPUT_TO_LOG
#ifndef JLIB_LOG2_ENABLED
#error 'You must include <jlib/log2.h> first!'
#else // has JLIB_LOG2_ENABLED
static
inline
void
myMessageOutput
(
QtMsgType
type
,
const
QMessageLogContext
&
context
,
const
QString
&
msg
)
{
using
namespace
jlib
;
QByteArray
localMsg
=
msg
.
toLocal8Bit
();
switch
(
type
)
{
case
QtDebugMsg
:
JLOG_INFO
(
localMsg
.
data
());
break
;
case
QtWarningMsg
:
if
(
!
msg
.
contains
(
"libpng"
))
{
JLOG_WARN
(
localMsg
.
data
());
}
break
;
case
QtCriticalMsg
:
JLOG_CRTC
(
localMsg
.
data
());
break
;
case
QtFatalMsg
:
JLOG_ERRO
(
localMsg
.
data
());
break
;
case
QtInfoMsg
:
JLOG_INFO
(
localMsg
.
data
());
break
;
default:
JLOG_WARN
(
localMsg
.
data
());
break
;
}
}
#endif // JLIB_LOG2_ENABLED
#endif // REDIRECT_QT_OUTPUT_TO_LOG
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