File tree Expand file tree Collapse file tree 8 files changed +36
-21
lines changed Expand file tree Collapse file tree 8 files changed +36
-21
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ var ExceptionSplit = "github.com/sirupsen/logrus/"
37
37
38
38
func (b * Exception ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
39
39
strStack := entry .Data ["stack" ].(string )
40
- return b .ToSave (strStack , entry .Message )
40
+
41
+ return (* b ).ToSave (strStack , entry .Message )
41
42
}
42
43
43
44
func (b * Exception ) ToSave (strStack , msg string ) (* entries , []tag ) {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ type Job struct {
23
23
Hostname string `json:"hostname"`
24
24
}
25
25
26
- func (b * Job ) Boot () {
26
+ func (j * Job ) Boot () {
27
27
if app2 .IsDebug () && app .HasBean ("queue" ) {
28
28
server := app .GetBean ("queue" ).(* servers.Queue )
29
29
server .AddMiddleware (func (job constraint.Job , next func (constraint.Job )) {
@@ -45,11 +45,13 @@ func (b *Job) Boot() {
45
45
}
46
46
}
47
47
48
- func (b * Job ) BindType () string {
48
+ func (j * Job ) BindType () string {
49
49
return "job"
50
50
}
51
51
52
- func (b * Job ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
52
+ func (j * Job ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
53
+ b := * j
54
+
53
55
b .Name = entry .Message
54
56
b .Data = entry .Data ["data" ]
55
57
b .Status = entry .Data ["status" ].(string )
Original file line number Diff line number Diff line change @@ -14,11 +14,13 @@ type Log struct {
14
14
Context map [string ]interface {} `json:"context"`
15
15
}
16
16
17
- func (b * Log ) BindType () string {
17
+ func (l * Log ) BindType () string {
18
18
return "log"
19
19
}
20
20
21
- func (b * Log ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
21
+ func (l * Log ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
22
+ b := * l
23
+
22
24
if entry .Level <= logrus .ErrorLevel {
23
25
hasError = true
24
26
defer func () {
Original file line number Diff line number Diff line change @@ -23,22 +23,24 @@ type Query struct {
23
23
Hostname string `json:"hostname"`
24
24
}
25
25
26
- func (b * Query ) Init () {
27
- b .Hostname , _ = os .Hostname ()
26
+ func (q * Query ) Init () {
27
+ q .Hostname , _ = os .Hostname ()
28
28
}
29
29
30
- func (b * Query ) BindType () string {
30
+ func (q * Query ) BindType () string {
31
31
return "query"
32
32
}
33
33
34
34
// QuerySplit 切割标识, 这个标识以后的代码才是业务的
35
35
var QuerySplit = "/app/entity/"
36
36
37
- func (b * Query ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
37
+ func (q * Query ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
38
38
if strings .Index (entry .Message , "telescope_" ) != - 1 {
39
39
return nil , nil
40
40
}
41
- b .File = ""
41
+
42
+ b := * q
43
+
42
44
// 根据模型目录 /app/entity/ 定位业务调用
43
45
stack := string (debug .Stack ())
44
46
arr := strings .Split (string (stack ), "\n " )
Original file line number Diff line number Diff line change @@ -16,14 +16,16 @@ type Redis struct {
16
16
Hostname string `json:"hostname"`
17
17
}
18
18
19
- func (b * Redis ) BindType () string {
19
+ func (r * Redis ) BindType () string {
20
20
return "redis"
21
21
}
22
22
23
23
// RedisSplit 切割标识, 这个标识以后的代码才是业务的
24
24
var RedisSplit = "github.com/sirupsen/logrus/"
25
25
26
- func (b * Redis ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
26
+ func (r * Redis ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
27
+ b := * r
28
+
27
29
file , line := GetStackCallFile (string (debug .Stack ()), RedisSplit )
28
30
29
31
b .Connection = file + ":" + line
Original file line number Diff line number Diff line change @@ -27,15 +27,17 @@ type Request struct {
27
27
Hostname string `json:"hostname,omitempty"`
28
28
}
29
29
30
- func (b * Request ) Init () {
31
- b .Hostname , _ = os .Hostname ()
30
+ func (req * Request ) Init () {
31
+ req .Hostname , _ = os .Hostname ()
32
32
}
33
33
34
- func (b * Request ) BindType () string {
34
+ func (req * Request ) BindType () string {
35
35
return "request"
36
36
}
37
37
38
- func (b * Request ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
38
+ func (req * Request ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
39
+ b := * req
40
+
39
41
b .Payload = make (map [string ]interface {})
40
42
41
43
uuId := uuid .NewV4 ().String ()
Original file line number Diff line number Diff line change @@ -17,11 +17,13 @@ type Schedule struct {
17
17
Hostname string `json:"hostname"`
18
18
}
19
19
20
- func (b * Schedule ) BindType () string {
20
+ func (s * Schedule ) BindType () string {
21
21
return "schedule"
22
22
}
23
23
24
- func (b * Schedule ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
24
+ func (s * Schedule ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
25
+ b := * s
26
+
25
27
b .Command = entry .Message
26
28
return & entries {
27
29
Uuid : uuid .NewV4 ().String (),
Original file line number Diff line number Diff line change @@ -24,13 +24,15 @@ type Tcp struct {
24
24
Hostname string `json:"hostname,omitempty"`
25
25
}
26
26
27
- func (b * Tcp ) BindType () string {
27
+ func (c * Tcp ) BindType () string {
28
28
return "tcp"
29
29
}
30
30
31
31
// Handler
32
32
// logrus.WithFields(logrus.Fields{"type": "tcp","read": raw,"tags": []string{str}}).Debug(tpc_route)
33
- func (b * Tcp ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
33
+ func (c * Tcp ) Handler (entry * logrus.Entry ) (* entries , []tag ) {
34
+ b := * c
35
+
34
36
ip , ok := entry .Data ["ip" ]
35
37
if ok {
36
38
b .IpAddress = ip .(string )
You can’t perform that action at this time.
0 commit comments