Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FmclientUi
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuai.liu
FmclientUi
Commits
de552c87
Commit
de552c87
authored
Sep 26, 2019
by
刘帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志标准化
去掉内容中的换行、添加交易号字段 [时间] [级别] [订单号] [日志内容]
parent
a7de2ce8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
19 deletions
+25
-19
QsLog/QsLog.cpp
+6
-5
QsLog/QsLog.h
+16
-13
main.cpp
+1
-1
qfmclient.cpp
+0
-0
qfmclient.h
+2
-0
No files found.
QsLog/QsLog.cpp
View file @
de552c87
...
...
@@ -44,13 +44,13 @@ typedef QVector<DestinationPtr> DestinationList;
static
const
char
TraceString
[]
=
"TRACE"
;
static
const
char
DebugString
[]
=
"DEBUG"
;
static
const
char
InfoString
[]
=
"INFO
"
;
static
const
char
WarnString
[]
=
"WARN
"
;
static
const
char
InfoString
[]
=
"INFO"
;
static
const
char
WarnString
[]
=
"WARN"
;
static
const
char
ErrorString
[]
=
"ERROR"
;
static
const
char
FatalString
[]
=
"FATAL"
;
// not using Qt::ISODate because we need the milliseconds too
static
const
QString
fmtDateTime
(
"yyyy-MM-dd hh:mm:ss
.
zzz"
);
static
const
QString
fmtDateTime
(
"yyyy-MM-dd hh:mm:ss
,
zzz"
);
static
const
char
*
LevelToText
(
Level
theLevel
)
{
...
...
@@ -217,9 +217,10 @@ Level Logger::loggingLevel() const
void
Logger
::
Helper
::
writeToLog
()
{
const
char
*
const
levelName
=
LevelToText
(
level
);
const
QString
completeMessage
(
QString
(
"%1 %2 %3"
)
.
arg
(
levelName
)
const
QString
completeMessage
(
QString
(
"%1 %2 %3 %4"
)
.
arg
(
QDateTime
::
currentDateTime
().
toString
(
fmtDateTime
))
.
arg
(
levelName
)
.
arg
(
trans_id
)
.
arg
(
buffer
)
);
...
...
QsLog/QsLog.h
View file @
de552c87
...
...
@@ -66,7 +66,9 @@ public:
level
(
logLevel
),
qtDebug
(
&
buffer
)
{}
~
Helper
();
QDebug
&
stream
(){
return
qtDebug
;
}
QDebug
&
stream
(
QString
_trans_id
){
trans_id
=
_trans_id
;
return
qtDebug
;
}
private
:
void
writeToLog
();
...
...
@@ -74,6 +76,7 @@ public:
Level
level
;
QString
buffer
;
QDebug
qtDebug
;
QString
trans_id
;
};
private
:
...
...
@@ -94,24 +97,24 @@ private:
//! Logging macros: define QS_LOG_LINE_NUMBERS to get the file and line number
//! in the log output.
#ifndef QS_LOG_LINE_NUMBERS
#define QLOG_TRACE() \
#define QLOG_TRACE(
TRANS_ID
) \
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::TraceLevel) {} \
else QsLogging::Logger::Helper(QsLogging::TraceLevel).stream()
#define QLOG_DEBUG() \
else QsLogging::Logger::Helper(QsLogging::TraceLevel).stream(
TRANS_ID
)
#define QLOG_DEBUG(
TRANS_ID
) \
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::DebugLevel) {} \
else QsLogging::Logger::Helper(QsLogging::DebugLevel).stream()
#define QLOG_INFO() \
else QsLogging::Logger::Helper(QsLogging::DebugLevel).stream(
TRANS_ID
)
#define QLOG_INFO(
TRANS_ID
) \
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::InfoLevel) {} \
else QsLogging::Logger::Helper(QsLogging::InfoLevel).stream()
#define QLOG_WARN() \
else QsLogging::Logger::Helper(QsLogging::InfoLevel).stream(
TRANS_ID
)
#define QLOG_WARN(
TRANS_ID
) \
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::WarnLevel) {} \
else QsLogging::Logger::Helper(QsLogging::WarnLevel).stream()
#define QLOG_ERROR() \
else QsLogging::Logger::Helper(QsLogging::WarnLevel).stream(
TRANS_ID
)
#define QLOG_ERROR(
TRANS_ID
) \
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::ErrorLevel) {} \
else QsLogging::Logger::Helper(QsLogging::ErrorLevel).stream()
#define QLOG_FATAL() \
else QsLogging::Logger::Helper(QsLogging::ErrorLevel).stream(
TRANS_ID
)
#define QLOG_FATAL(
TRANS_ID
) \
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::FatalLevel) {} \
else QsLogging::Logger::Helper(QsLogging::FatalLevel).stream()
else QsLogging::Logger::Helper(QsLogging::FatalLevel).stream(
TRANS_ID
)
#else
#define QLOG_TRACE() \
if (QsLogging::Logger::instance().loggingLevel() > QsLogging::TraceLevel) {} \
...
...
main.cpp
View file @
de552c87
...
...
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
return
0
;
}
InitLogger
();
QLOG_INFO
()
<<
"start FmclientUi..."
;
QLOG_INFO
(
DEFAULT_TRANS_ID
)
<<
"start FmclientUi..."
;
Widget
w
;
scanner
s
;
QFmClient
client
;
...
...
qfmclient.cpp
View file @
de552c87
This diff is collapsed.
Click to expand it.
qfmclient.h
View file @
de552c87
...
...
@@ -22,6 +22,7 @@
#define MAX_BUF_LEN 25600
#define MAX_REQ_COUNT 25600
#define ROLL_BACK_FILE_NAME "fmclient.rbk"
#define DEFAULT_TRANS_ID "invalid"
class
QFmClient
:
public
QThread
{
...
...
@@ -117,6 +118,7 @@ public:
QString
_refundTransId
;
QString
mTransId
;
//for log
static
unsigned
int
s_reqCount
;
};
...
...
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