Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
familyMart_takeaway
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
guanghui.cui
familyMart_takeaway
Commits
f2e6ab1f
Commit
f2e6ab1f
authored
Jul 18, 2022
by
wuyang.zou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix : 日志人性化输出
parent
1ad7d4a4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
24 deletions
+88
-24
bin/PosRequestInitData.json
+2
-2
bin/SimulatorPosBin/config.ini
+29
-0
bin/SimulatorPosBin/log.conf
+31
-0
bin/config.ini
+2
-1
src/PosHandle.cpp
+4
-4
src/main.cpp
+13
-10
utility/utility.cpp
+7
-7
No files found.
bin/PosRequestInitData.json
View file @
f2e6ab1f
{
"fm_cmd"
:
1000
,
"listen_port"
:
24445
,
"storeId"
:
"208888"
,
"pos_id"
:
"5"
,
"operator_id"
:
"zouwuyang"
,
"is_master"
:
false
,
"plugin_comment"
:
"123.60.107.183"
,
"ver"
:
1
,
"version"
:
"1.3.1 RC"
}
{
"fm_cmd"
:
1000
,
"listen_port"
:
24445
,
"storeId"
:
"208888"
,
"pos_id"
:
"6"
,
"operator_id"
:
"zouwuyang"
,
"is_master"
:
false
,
"plugin_comment"
:
"123.60.107.183"
,
"ver"
:
1
,
"version"
:
"1.3.1 RC"
}
\ No newline at end of file
\ No newline at end of file
bin/SimulatorPosBin/config.ini
0 → 100644
View file @
f2e6ab1f
[SYS]
port
=
24446
#<<全家>
#config.ini 文件 中 [ODS] 模块中的
#(生产环境外网 IP [内网IP:10.251.100.70] )
#ip: 123.60.107.182
#(测试环境外网 IP [内网IP:10.251.102.14] )
#ip: 123.60.107.183
[ODS]
# ip=api.ods.chinafamilymart.com.cn
ip
=
123.60.107.183
pushPort
=
30001
recvPort
=
30002
socketTimeout
=
120
[POS]
ip
=
127.0.0.1
port
=
24445
;Windows 模拟程序 新增可配置功能:
;配置门店号, POS号, 是否主POS标识, 插件模拟角色: 默认是插件(可控制是否自动登录) / simulatorRole=pos 标识模拟POS发送登录请求;
storeId
=
208888
posId
=
6
isMaster
=
false
simulatorRole
=
pos
;autoLogin=true
bin/SimulatorPosBin/log.conf
0 → 100644
View file @
f2e6ab1f
*
GLOBAL
:
ENABLED
=
true
TO_FILE
=
true
TO_STANDARD_OUTPUT
=
true
FORMAT
=
"[%level | %datetime] | %msg"
FILENAME
=
"./logs/log.log"
MILLISECONDS_WIDTH
=
3
PERFORMANCE_TRACKING
=
false
MAX_LOG_FILE_SIZE
=
20485760
LOG_FLUSH_THRESHOLD
=
10
*
TRACE
:
FILENAME
=
"./logs/trace_log.log"
*
DEBUG
:
FILENAME
=
"./logs/debug_log.log"
*
FATAL
:
ENABLED
=
false
*
ERROR
:
FILENAME
=
"./logs/error_log.log"
*
WARNING
:
FILENAME
=
"./logs/warning_log.log"
*
INFO
:
FILENAME
=
"./logs/info_log.log"
*
VERBOSE
:
ENABLED
=
false
bin/config.ini
View file @
f2e6ab1f
...
@@ -9,7 +9,8 @@ port=24446
...
@@ -9,7 +9,8 @@ port=24446
#ip: 123.60.107.183
#ip: 123.60.107.183
[ODS]
[ODS]
ip
=
api.ods.chinafamilymart.com.cn
# ip=api.ods.chinafamilymart.com.cn
ip
=
123.60.107.183
pushPort
=
30001
pushPort
=
30001
recvPort
=
30002
recvPort
=
30002
...
...
src/PosHandle.cpp
View file @
f2e6ab1f
...
@@ -36,9 +36,9 @@ void* PosHandle::listen_pos_func(void* arg) {
...
@@ -36,9 +36,9 @@ void* PosHandle::listen_pos_func(void* arg) {
JsonModule
jsonTool
;
JsonModule
jsonTool
;
if
(
server
.
doListen
(
client_listen_port
))
{
// 监控Plugin本地端口: Plugin Liston -> port [24446]
if
(
server
.
doListen
(
client_listen_port
))
{
// 监控Plugin本地端口: Plugin Liston -> port [24446]
LOG
(
INFO
)
<<
"[PosPlugin] Listen Port: ["
<<
client_listen_port
<<
"] Successful,
Recv [POS]
Request"
<<
'\n'
;
LOG
(
INFO
)
<<
"[PosPlugin] Listen Port: ["
<<
client_listen_port
<<
"] Successful,
Wait Recv [POS]
Request"
<<
'\n'
;
}
else
{
}
else
{
LOG
(
INFO
)
<<
"[PosPlugin] Listen Port: ["
<<
client_listen_port
<<
"] Failed,
Maybe Instance Is Exist, Exit!!!"
;
LOG
(
INFO
)
<<
"[PosPlugin] Listen Port: ["
<<
client_listen_port
<<
"] Failed, Maybe Instance Is Exist, Exit!!!"
;
exit
(
0
);
exit
(
0
);
}
}
...
@@ -234,7 +234,7 @@ void* PosHandle::listen_pos_func(void* arg) {
...
@@ -234,7 +234,7 @@ void* PosHandle::listen_pos_func(void* arg) {
void
PosHandle
::
getIpByDns
(
IN
std
::
string
&
ods_ip
)
{
void
PosHandle
::
getIpByDns
(
IN
std
::
string
&
ods_ip
)
{
if
(
ods_ip
.
front
()
<
'0'
||
ods_ip
.
front
()
>
'9'
)
{
if
(
ods_ip
.
front
()
<
'0'
||
ods_ip
.
front
()
>
'9'
)
{
LOG
(
INFO
)
<<
"DNS Resolve IP Begin
, Origin ods_ip: "
<<
ods_ip
.
c_str
()
;
LOG
(
INFO
)
<<
"DNS Resolve IP Begin
, Origin ods_ip: "
<<
ods_ip
.
c_str
()
<<
std
::
endl
;
struct
hostent
*
pHost
=
NULL
;
struct
hostent
*
pHost
=
NULL
;
bool
bGetDnsRet
=
false
;
bool
bGetDnsRet
=
false
;
// 需考虑POS机断网后,域名解析会频繁失败,频繁失败,插件有退出程序的可能,故在此进行类似死循环处理,插件永不主动退出;
// 需考虑POS机断网后,域名解析会频繁失败,频繁失败,插件有退出程序的可能,故在此进行类似死循环处理,插件永不主动退出;
...
@@ -530,7 +530,7 @@ bool PosHandle::simulator_pos_send_init() {
...
@@ -530,7 +530,7 @@ bool PosHandle::simulator_pos_send_init() {
LOG
(
INFO
)
<<
"Simulator Pos Send Login Request ===>> PosPlugin "
<<
g_simulator_pos_req_data
.
data
();
LOG
(
INFO
)
<<
"Simulator Pos Send Login Request ===>> PosPlugin "
<<
g_simulator_pos_req_data
.
data
();
LOG
(
INFO
)
<<
"Simulator Pos Connect pos_ip: "
<<
pos_ip
.
c_str
()
<<
" Port:"
<<
client_listen_port
;
LOG
(
INFO
)
<<
"Simulator Pos Connect pos_ip: "
<<
pos_ip
.
c_str
()
<<
" Port:"
<<
client_listen_port
;
if
(
g_simulator_pos_client
.
doConnect
(
client_listen_port
,
pos_ip
.
c_str
()))
{
if
(
g_simulator_pos_client
.
doConnect
(
client_listen_port
,
pos_ip
.
c_str
()))
{
g_simulator_pos_client
.
setSocketTimeout
(
5
);
//设置超时
g_simulator_pos_client
.
setSocketTimeout
(
120
);
//设置超时
if
(
g_simulator_pos_client
.
write
(
g_simulator_pos_req_data
.
data
()))
{
if
(
g_simulator_pos_client
.
write
(
g_simulator_pos_req_data
.
data
()))
{
//等待POS-Plugin返回初始化结果
//等待POS-Plugin返回初始化结果
...
...
src/main.cpp
View file @
f2e6ab1f
...
@@ -66,8 +66,8 @@ std::string g_plugin_relogin_ods_reason; // 插件重新登录 ODS 的原因;
...
@@ -66,8 +66,8 @@ std::string g_plugin_relogin_ods_reason; // 插件重新登录 ODS 的原因;
#ifdef WIN32
#ifdef WIN32
bool
bInitDone
=
false
;
//初始化完成
bool
bInitDone
=
false
;
//初始化完成
std
::
string
g_pluginAppName
=
"takeaway_d"
;
std
::
string
g_pluginAppName
=
"takeaway_d"
;
std
::
string
g_psAppFullName
=
"
E:
\\
zouwuyang
\\
FamilyMart
\\
PosPluginClien
t
\\
familyMart_takeaway
\\
bin
\\
ps"
;
std
::
string
g_psAppFullName
=
"
D:
\\
DEV_CODE
\\
FamilyMar
t
\\
familyMart_takeaway
\\
bin
\\
ps"
;
std
::
string
g_appBootStriptFile
=
"
E:
\\
zouwuyang
\\
FamilyMart
\\
PosPluginClien
t
\\
familyMart_takeaway
\\
bin
\\
run_cream.sh"
;
std
::
string
g_appBootStriptFile
=
"
D:
\\
DEV_CODE
\\
FamilyMar
t
\\
familyMart_takeaway
\\
bin
\\
run_cream.sh"
;
#else
#else
bool
bInitDone
=
false
;
//初始化完成
bool
bInitDone
=
false
;
//初始化完成
std
::
string
g_pluginAppName
=
"takeaway"
;
std
::
string
g_pluginAppName
=
"takeaway"
;
...
@@ -105,8 +105,8 @@ int main(int argc,char *argv[])
...
@@ -105,8 +105,8 @@ int main(int argc,char *argv[])
JsonModule
jsonToolTemp
;
JsonModule
jsonToolTemp
;
LOG
(
INFO
)
<<
"
---------software start---------
"
;
LOG
(
INFO
)
<<
"
<-----------Software Start----------->
"
;
LOG
(
INFO
)
<<
"
version:
"
<<
g_plugin_version
;
LOG
(
INFO
)
<<
"
Version:
"
<<
g_plugin_version
;
// 读取配置文件信息
// 读取配置文件信息
std
::
string
strIniPath
(
strBinPath
.
data
());
std
::
string
strIniPath
(
strBinPath
.
data
());
strIniPath
.
append
(
"config.ini"
);
strIniPath
.
append
(
"config.ini"
);
...
@@ -156,11 +156,11 @@ int main(int argc,char *argv[])
...
@@ -156,11 +156,11 @@ int main(int argc,char *argv[])
+
"
\"
,
\"
version
\"
:
\"
"
+
g_plugin_version
+
"
\"
,
\"
listen_port
\"
:24445 }"
;
+
"
\"
,
\"
version
\"
:
\"
"
+
g_plugin_version
+
"
\"
,
\"
listen_port
\"
:24445 }"
;
}
}
LOG
(
INFO
)
<<
"[ODS]ip: "
<<
ods_ip
.
data
()
<<
"
-push port: "
<<
ods_push_port
<<
"-recv port: "
<<
ods_recv_port
<<
"-
socket timeout: "
<<
ods_socket_timeout
;
LOG
(
INFO
)
<<
"[ODS]ip: "
<<
ods_ip
.
data
()
<<
"
->push port: "
<<
ods_push_port
<<
" ->recv port: "
<<
ods_recv_port
<<
" ->
socket timeout: "
<<
ods_socket_timeout
;
LOG
(
INFO
)
<<
"[POS]ip: "
<<
pos_ip
<<
"
-listen port:"
<<
pos_listen_port
<<
" storeId:"
<<
pos_config_storeid
<<
" posId:"
<<
pos_config_posid
<<
"
is_master:"
<<
pos_config_ismaster
;
LOG
(
INFO
)
<<
"[POS]ip: "
<<
pos_ip
<<
"
->listen port:"
<<
pos_listen_port
<<
" ->storeId:"
<<
pos_config_storeid
<<
" ->posId:"
<<
pos_config_posid
<<
" ->
is_master:"
<<
pos_config_ismaster
;
#else
#else
LOG
(
INFO
)
<<
"[ODS]ip: "
<<
ods_ip
.
data
()
<<
"
-push port: "
<<
ods_push_port
<<
"-recv port: "
<<
ods_recv_port
<<
"-
socket timeout: "
<<
ods_socket_timeout
;
LOG
(
INFO
)
<<
"[ODS]ip: "
<<
ods_ip
.
data
()
<<
"
->push port: "
<<
ods_push_port
<<
" ->recv port: "
<<
ods_recv_port
<<
" ->
socket timeout: "
<<
ods_socket_timeout
;
LOG
(
INFO
)
<<
"[POS]ip: "
<<
pos_ip
<<
"
-
listen port: "
<<
pos_listen_port
;
LOG
(
INFO
)
<<
"[POS]ip: "
<<
pos_ip
<<
"
->
listen port: "
<<
pos_listen_port
;
#endif
#endif
LOG
(
INFO
)
<<
"[PosPlugin] Listen Port: "
<<
client_listen_port
;
LOG
(
INFO
)
<<
"[PosPlugin] Listen Port: "
<<
client_listen_port
;
...
@@ -210,11 +210,11 @@ int main(int argc,char *argv[])
...
@@ -210,11 +210,11 @@ int main(int argc,char *argv[])
#ifdef WIN32
#ifdef WIN32
// Test Add New Feature Convert Result: Column Field
// Test Add New Feature Convert Result: Column Field
std
::
string
testOrderJson
=
jsonToolTemp
.
getTestOrderJson
();
std
::
string
testOrderJson
=
jsonToolTemp
.
getTestOrderJson
();
LOG
(
INFO
)
<<
"----------- Plugin Read Local Test Order File Success ------------"
<<
testOrderJson
<<
'\n'
;
if
(
testOrderJson
.
length
())
{
if
(
testOrderJson
.
length
())
{
LOG
(
INFO
)
<<
"----------- Plugin Read Local Test Order File Success ------------"
<<
testOrderJson
<<
'\n'
;
std
::
string
convertTestOrderJson
=
jsonToolTemp
.
getConvertOrderJson
(
testOrderJson
);
std
::
string
convertTestOrderJson
=
jsonToolTemp
.
getConvertOrderJson
(
testOrderJson
);
if
(
testOrderJson
.
length
()
&&
convertTestOrderJson
.
length
())
{
if
(
testOrderJson
.
length
()
&&
convertTestOrderJson
.
length
())
{
LOG
(
INFO
)
<<
"----------- Plugin
Read&Convert Local Test Order File
Success ------------"
;
LOG
(
INFO
)
<<
"----------- Plugin
Read & Convert Local Test Order File
Success ------------"
;
LOG
(
INFO
)
<<
charset_u2g
(
convertTestOrderJson
);
LOG
(
INFO
)
<<
charset_u2g
(
convertTestOrderJson
);
LOG
(
INFO
)
<<
"----------No charset_u2g(*)-------------"
;
LOG
(
INFO
)
<<
"----------No charset_u2g(*)-------------"
;
LOG
(
INFO
)
<<
convertTestOrderJson
;
LOG
(
INFO
)
<<
convertTestOrderJson
;
...
@@ -323,7 +323,10 @@ int main(int argc,char *argv[])
...
@@ -323,7 +323,10 @@ int main(int argc,char *argv[])
LOG
(
INFO
)
<<
"PosPlugin Haven't Receive Pos Init Tcp Data, Check Pos Listen Port Is Ok, Prepare Login ODS...... "
;
LOG
(
INFO
)
<<
"PosPlugin Haven't Receive Pos Init Tcp Data, Check Pos Listen Port Is Ok, Prepare Login ODS...... "
;
g_init_data
=
g_local_pos_init_data
;
g_init_data
=
g_local_pos_init_data
;
bInitDone
=
true
;
bInitDone
=
true
;
}
else
{
LOG
(
INFO
)
<<
"PosPlugin Haven't Receive Pos Init Tcp Data And Pos Service Haven't Exist, Still Waitting..."
;
}
}
}
}
if
(
waitPosInitReqTimeOutCount
<
6
)
{
if
(
waitPosInitReqTimeOutCount
<
6
)
{
...
...
utility/utility.cpp
View file @
f2e6ab1f
...
@@ -318,7 +318,7 @@ void create_process_daemon() {
...
@@ -318,7 +318,7 @@ void create_process_daemon() {
WIN32_FIND_DATA
wfd
;
WIN32_FIND_DATA
wfd
;
HANDLE
hFind
=
FindFirstFile
(
strDaemonAppPath
.
c_str
()
,
&
wfd
);
HANDLE
hFind
=
FindFirstFile
(
strDaemonAppPath
.
c_str
()
,
&
wfd
);
if
(
INVALID_HANDLE_VALUE
==
hFind
)
{
if
(
INVALID_HANDLE_VALUE
==
hFind
)
{
LOG
(
INFO
)
<<
"strDaemonAppPath:"
<<
strDaemonAppPath
.
c_str
()
<<
" No Exist !!!"
;
LOG
(
INFO
)
<<
"strDaemonAppPath:
"
<<
strDaemonAppPath
.
c_str
()
<<
" No Exist !!!"
;
return
;
return
;
}
}
else
{
else
{
...
@@ -336,7 +336,7 @@ void create_process_daemon() {
...
@@ -336,7 +336,7 @@ void create_process_daemon() {
// WaitForSingleObject(pi.hProcess, INFINITE);
// WaitForSingleObject(pi.hProcess, INFINITE);
// CloseHandle(pi.hProcess);
// CloseHandle(pi.hProcess);
// system("start regedit.exe"); // Meybe Block Main Process;
// system("start regedit.exe"); // Meybe Block Main Process;
LOG
(
INFO
)
<<
"Start Another Process Success
, DaemonAppPath:
"
<<
strDaemonAppPath
.
c_str
();
LOG
(
INFO
)
<<
"Start Another Process Success
, DaemonAppPath:
"
<<
strDaemonAppPath
.
c_str
();
}
}
#else
#else
...
@@ -348,15 +348,15 @@ void create_process_daemon() {
...
@@ -348,15 +348,15 @@ void create_process_daemon() {
// 判断 fmtakeout 目录下是否存在 有可执行权限的 fmPluginDaemon 程序
// 判断 fmtakeout 目录下是否存在 有可执行权限的 fmPluginDaemon 程序
if
(
access
(
strDaemonAppPath
.
c_str
(),
X_OK
)
==
0
)
{
if
(
access
(
strDaemonAppPath
.
c_str
(),
X_OK
)
==
0
)
{
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonAppPath:"
<<
strDaemonAppPath
.
c_str
()
<<
" Exist And Has Execute Permission "
;
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonAppPath:
"
<<
strDaemonAppPath
.
c_str
()
<<
" Exist And Has Execute Permission "
;
}
else
{
}
else
{
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonAppPath:"
<<
strDaemonAppPath
.
c_str
()
<<
" Non-Exist Or No Execute Permission "
;
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonAppPath:
"
<<
strDaemonAppPath
.
c_str
()
<<
" Non-Exist Or No Execute Permission "
;
return
;
return
;
}
}
// 判断 fmtakeout 目录下是否存在 有可执行权限的 ps 程序
// 判断 fmtakeout 目录下是否存在 有可执行权限的 ps 程序
if
(
access
(
g_psAppFullName
.
c_str
(),
X_OK
)
==
0
)
{
if
(
access
(
g_psAppFullName
.
c_str
(),
X_OK
)
==
0
)
{
LOG
(
INFO
)
<<
"create_process_daemon:: psAppPath:"
<<
g_psAppFullName
.
c_str
()
<<
" Exist And Has Execute Permission "
;
LOG
(
INFO
)
<<
"create_process_daemon:: psAppPath:
"
<<
g_psAppFullName
.
c_str
()
<<
" Exist And Has Execute Permission "
;
}
}
else
{
else
{
LOG
(
INFO
)
<<
"create_process_daemon:: psAppPath:"
<<
g_psAppFullName
.
c_str
()
<<
" Non-Exist Or No Execute Permission "
;
LOG
(
INFO
)
<<
"create_process_daemon:: psAppPath:"
<<
g_psAppFullName
.
c_str
()
<<
" Non-Exist Or No Execute Permission "
;
...
@@ -367,7 +367,7 @@ void create_process_daemon() {
...
@@ -367,7 +367,7 @@ void create_process_daemon() {
if
(
does_daemon_work
()
)
if
(
does_daemon_work
()
)
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonApp: Is Running No Need Run Another One"
;
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonApp: Is Running No Need Run Another One"
;
else
{
else
{
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonApp: Haven't Run, Start DaemonApp Now
"
;
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonApp: Haven't Run, Start DaemonApp Now"
;
// 4、启动daemon程序;
// 4、启动daemon程序;
system
(
strDaemonAppPath
.
c_str
()
);
system
(
strDaemonAppPath
.
c_str
()
);
}
}
...
@@ -378,7 +378,7 @@ void create_process_daemon() {
...
@@ -378,7 +378,7 @@ void create_process_daemon() {
int
does_daemon_work
()
int
does_daemon_work
()
{
{
#ifdef WIN32
#ifdef WIN32
LOG
(
INFO
)
<<
"does_daemon_work:: DaemonApp Is Running, No Need Check Status
"
;
LOG
(
INFO
)
<<
"does_daemon_work:: DaemonApp Is Running, No Need Check Status"
;
return
1
;
return
1
;
#else
#else
...
...
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