Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
LC_soapi
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1dadd8a3
authored
Jan 07, 2020
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善日志格式
parent
40b95f7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
pkg/http/response.go → pkg/app/response.go
pkg/logging/log_report.go
pkg/
htt
p/response.go
→
pkg/
ap
p/response.go
View file @
1dadd8a3
package
ap
p
package
htt
p
import
(
import
(
"LC_soapi/pkg/logging"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
)
)
...
@@ -15,10 +16,15 @@ type Response struct {
...
@@ -15,10 +16,15 @@ type Response struct {
}
}
// Response setting gin.JSON
// Response setting gin.JSON
func
(
g
*
Gin
)
Response
(
errCode
int
,
errMsg
string
,
data
interface
{})
{
func
(
g
*
Gin
)
Response
(
code
int
,
msg
string
,
data
interface
{})
{
if
code
>
100
{
logging
.
ReportErrorLog
(
code
,
msg
,
g
.
C
.
ClientIP
())
}
g
.
C
.
JSON
(
200
,
Response
{
g
.
C
.
JSON
(
200
,
Response
{
Code
:
errC
ode
,
Code
:
c
ode
,
Msg
:
errM
sg
,
Msg
:
m
sg
,
Data
:
data
,
Data
:
data
,
})
})
return
return
...
...
pkg/logging/log_report.go
View file @
1dadd8a3
...
@@ -22,7 +22,7 @@ type ErrorLog struct {
...
@@ -22,7 +22,7 @@ type ErrorLog struct {
}
}
//上报请求日志
//上报请求日志
func
ReportErrorLog
(
msg
string
,
code
int
,
method
string
,
ip
string
)
{
func
ReportErrorLog
(
code
int
,
msg
string
,
ip
string
)
{
var
errLog
ErrorLog
var
errLog
ErrorLog
//获取调用者信息
//获取调用者信息
caller
:=
util
.
GetCaller
(
2
)
caller
:=
util
.
GetCaller
(
2
)
...
@@ -32,7 +32,7 @@ func ReportErrorLog(msg string, code int, method string,ip string) {
...
@@ -32,7 +32,7 @@ func ReportErrorLog(msg string, code int, method string,ip string) {
errLog
.
App
=
setting
.
AppSetting
.
Name
errLog
.
App
=
setting
.
AppSetting
.
Name
errLog
.
ServerIp
=
ip
errLog
.
ServerIp
=
ip
errLog
.
Method
=
"g.G.Routes()"
errLog
.
Method
=
caller
.
FunctionName
errLog
.
FileName
=
caller
.
FileName
errLog
.
FileName
=
caller
.
FileName
errLog
.
LineNo
=
caller
.
FileLine
errLog
.
LineNo
=
caller
.
FileLine
logString
,
_
:=
json
.
Marshal
(
errLog
)
logString
,
_
:=
json
.
Marshal
(
errLog
)
...
...
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