Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengqiuyun
rym-util
Commits
1ebe242b
Commit
1ebe242b
authored
Aug 25, 2022
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql加入连接配置
parent
61b53bee
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
25 deletions
+46
-25
conf.go
conf/conf.go
+1
-0
EsLogger.go
es/EsLogger.go
+5
-0
Header.go
getWay/Header.go
+40
-13
Request.go
getWay/Request.go
+0
-12
No files found.
conf/conf.go
View file @
1ebe242b
...
@@ -58,6 +58,7 @@ var LogLevel = "DEBUG"
...
@@ -58,6 +58,7 @@ var LogLevel = "DEBUG"
var
LogColorful
=
true
var
LogColorful
=
true
var
LogResponseLength
int
var
LogResponseLength
int
var
LogShowSql
=
true
var
LogShowSql
=
true
var
LogIndexNamePrefix
=
""
//Redis conf
//Redis conf
type
RedisConf
struct
{
type
RedisConf
struct
{
...
...
es/EsLogger.go
View file @
1ebe242b
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"context"
"context"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"git.168cad.top/zhengqiuyun/rym-util/conf"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"git.168cad.top/zhengqiuyun/rym-util/log"
"git.168cad.top/zhengqiuyun/rym-util/log"
"git.168cad.top/zhengqiuyun/rym-util/util"
"git.168cad.top/zhengqiuyun/rym-util/util"
...
@@ -13,7 +14,11 @@ import (
...
@@ -13,7 +14,11 @@ import (
)
)
func
getCurrentIndex
()
string
{
func
getCurrentIndex
()
string
{
if
conf
.
LogIndexNamePrefix
==
""
{
return
indexNamePrefix
+
util
.
FormatDates
(
time
.
Now
())
return
indexNamePrefix
+
util
.
FormatDates
(
time
.
Now
())
}
else
{
return
conf
.
LogIndexNamePrefix
+
util
.
FormatDates
(
time
.
Now
())
}
}
}
type
ServerLogModel
struct
{
type
ServerLogModel
struct
{
...
...
getWay/Header.go
View file @
1ebe242b
package
getWay
package
getWay
import
(
import
(
"git.168cad.top/zhengqiuyun/rym-util/util"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
)
)
const
headerKeyToken
=
"token"
const
(
headerKeyToken
=
"token"
const
headerKeyPlatformCode
=
"platform"
headerKeyPlatform
=
"platform"
headerKeyAppId
=
"appId"
headerKeyTimeStamp
=
"timeStamp"
headerKeySign
=
"sign"
)
const
headerKeyClientSource
=
"clientSource"
const
headerKeyClientSource
=
"clientSource"
func
getHeader
(
c
*
gin
.
Context
,
key
string
)
string
{
v
:=
c
.
GetHeader
(
key
)
return
v
}
func
GetToken
(
c
*
gin
.
Context
)
string
{
func
GetToken
(
c
*
gin
.
Context
)
string
{
return
getHeader
(
c
,
headerKeyToken
)
return
c
.
GetHeader
(
headerKeyToken
)
}
}
func
SetToken
(
v
string
,
c
*
gin
.
Context
)
{
func
SetToken
(
v
string
,
c
*
gin
.
Context
)
{
c
.
Header
(
headerKeyToken
,
v
)
c
.
Header
(
headerKeyToken
,
v
)
}
}
func
GetPlatformCode
(
c
*
gin
.
Context
)
string
{
func
GetAppId
(
c
*
gin
.
Context
)
string
{
platformCode
:=
getHeader
(
c
,
headerKeyPlatformCode
)
return
c
.
GetHeader
(
headerKeyAppId
)
}
func
GetTimeStamp
(
c
*
gin
.
Context
)
string
{
return
c
.
GetHeader
(
headerKeyTimeStamp
)
}
func
GetSign
(
c
*
gin
.
Context
)
string
{
return
c
.
GetHeader
(
headerKeySign
)
}
func
GetPlatform
(
c
*
gin
.
Context
)
string
{
platformCode
:=
c
.
GetHeader
(
headerKeyPlatform
)
return
platformCode
return
platformCode
}
}
func
GetClientSource
(
c
*
gin
.
Context
)
string
{
func
GetClientSource
(
c
*
gin
.
Context
)
string
{
platformCode
:=
getHeader
(
c
,
headerKeyClientSource
)
h
:=
c
.
GetHeader
(
headerKeyClientSource
)
return
platformCode
if
h
==
""
{
return
util
.
GetInterfaceToString
(
clientSource
{
AppId
:
GetAppId
(
c
),
TimeStamp
:
GetTimeStamp
(
c
),
Sign
:
GetSign
(
c
),
Platform
:
GetPlatform
(
c
),
})
}
return
h
}
type
clientSource
struct
{
AppId
string
`json:"appId"`
TimeStamp
string
`json:"timeStamp"`
Sign
string
`json:"sign"`
Platform
string
`json:"platform"`
}
}
getWay/Request.go
View file @
1ebe242b
...
@@ -116,15 +116,3 @@ func GetStartTime(c *gin.Context) int64 {
...
@@ -116,15 +116,3 @@ func GetStartTime(c *gin.Context) int64 {
func
logStart
(
c
*
gin
.
Context
)
{
func
logStart
(
c
*
gin
.
Context
)
{
log
.
Info
(
fmt
.
Sprintf
(
"开始 %s %s %s %s"
,
GetMethod
(
c
),
GetURL
(
c
),
GetToken
(
c
),
GetClientIP
(
c
)))
log
.
Info
(
fmt
.
Sprintf
(
"开始 %s %s %s %s"
,
GetMethod
(
c
),
GetURL
(
c
),
GetToken
(
c
),
GetClientIP
(
c
)))
}
}
func
GetAppId
(
c
*
gin
.
Context
)
string
{
return
c
.
GetHeader
(
"appId"
)
}
func
GetTimeStamp
(
c
*
gin
.
Context
)
string
{
return
c
.
GetHeader
(
"timeStamp"
)
}
func
GetSign
(
c
*
gin
.
Context
)
string
{
return
c
.
GetHeader
(
"sign"
)
}
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