diff --git a/type_exception.go b/type_exception.go index 9f757e7..cb0c017 100644 --- a/type_exception.go +++ b/type_exception.go @@ -23,7 +23,7 @@ type Exception struct { Occurrences int `json:"occurrences"` } -func (b Exception) BindType() string { +func (b *Exception) BindType() string { return "exception" } @@ -32,15 +32,15 @@ type trace struct { Line string `json:"line"` } -// 切割标识, 这个标识以后的代码才是业务的 +// ExceptionSplit 切割标识, 这个标识以后的代码才是业务的 var ExceptionSplit = "github.com/sirupsen/logrus/" -func (b Exception) Handler(entry *logrus.Entry) (*entries, []tag) { +func (b *Exception) Handler(entry *logrus.Entry) (*entries, []tag) { strStack := entry.Data["stack"].(string) return b.ToSave(strStack, entry.Message) } -func (b Exception) ToSave(strStack, msg string) (*entries, []tag) { +func (b *Exception) ToSave(strStack, msg string) (*entries, []tag) { b.Message = msg b.Trace = make([]trace, 0) b.LinePreview = make(map[int]string) diff --git a/type_job.go b/type_job.go index 03e52ee..da71eef 100644 --- a/type_job.go +++ b/type_job.go @@ -23,7 +23,7 @@ type Job struct { Hostname string `json:"hostname"` } -func (b Job) Boot() { +func (b *Job) Boot() { if app2.IsDebug() && app.HasBean("queue") { server := app.GetBean("queue").(*servers.Queue) server.AddMiddleware(func(job constraint.Job, next func(constraint.Job)) { @@ -45,11 +45,11 @@ func (b Job) Boot() { } } -func (b Job) BindType() string { +func (b *Job) BindType() string { return "job" } -func (b Job) Handler(entry *logrus.Entry) (*entries, []tag) { +func (b *Job) Handler(entry *logrus.Entry) (*entries, []tag) { b.Name = entry.Message b.Data = entry.Data["data"] b.Status = entry.Data["status"].(string) diff --git a/type_log.go b/type_log.go index c2981c0..cde6d58 100644 --- a/type_log.go +++ b/type_log.go @@ -14,11 +14,11 @@ type Log struct { Context map[string]interface{} `json:"context"` } -func (b Log) BindType() string { +func (b *Log) BindType() string { return "log" } -func (b Log) Handler(entry *logrus.Entry) (*entries, []tag) { +func (b *Log) Handler(entry *logrus.Entry) (*entries, []tag) { if entry.Level <= logrus.ErrorLevel { defer func() { telescopeEntries, tags := NewException().ToSave(string(debug.Stack()), entry.Message) @@ -29,9 +29,9 @@ func (b Log) Handler(entry *logrus.Entry) (*entries, []tag) { b.Message = entry.Message b.Context = entry.Data b.Level = entry.Level.String() - uuid := uuid.NewV4().String() + id := uuid.NewV4().String() return &entries{ - Uuid: uuid, + Uuid: id, BatchId: NewtelescopeHook().TelescopeUUID(), FamilyHash: nil, ShouldDisplayOnIndex: 1, @@ -39,7 +39,7 @@ func (b Log) Handler(entry *logrus.Entry) (*entries, []tag) { Content: ToContent(b), CreatedAt: time.Now().Format("2006-01-02 15:04:05"), }, []tag{{ - EntryUuid: uuid, + EntryUuid: id, Tag: b.Level, }} } diff --git a/type_query.go b/type_query.go index 66018a9..0b739f5 100644 --- a/type_query.go +++ b/type_query.go @@ -23,18 +23,18 @@ type Query struct { Hostname string `json:"hostname"` } -func (b Query) Init() { +func (b *Query) Init() { b.Hostname, _ = os.Hostname() } -func (b Query) BindType() string { +func (b *Query) BindType() string { return "query" } // QuerySplit 切割标识, 这个标识以后的代码才是业务的 var QuerySplit = "/app/entity/" -func (b Query) Handler(entry *logrus.Entry) (*entries, []tag) { +func (b *Query) Handler(entry *logrus.Entry) (*entries, []tag) { if strings.Index(entry.Message, "telescope_") != -1 { return nil, nil } @@ -70,9 +70,9 @@ func (b Query) Handler(entry *logrus.Entry) (*entries, []tag) { b.File, b.Line = GetStackCallFile(stack, "go-home-admin/home/bootstrap/services/logs/mysql") } - uuid := uuid.NewV4().String() + id := uuid.NewV4().String() return &entries{ - Uuid: uuid, + Uuid: id, BatchId: NewtelescopeHook().TelescopeUUID(), FamilyHash: nil, ShouldDisplayOnIndex: 1, diff --git a/type_redis.go b/type_redis.go index b859861..fd8a4be 100644 --- a/type_redis.go +++ b/type_redis.go @@ -16,14 +16,14 @@ type Redis struct { Hostname string `json:"hostname"` } -func (b Redis) BindType() string { +func (b *Redis) BindType() string { return "redis" } // RedisSplit 切割标识, 这个标识以后的代码才是业务的 var RedisSplit = "github.com/sirupsen/logrus/" -func (b Redis) Handler(entry *logrus.Entry) (*entries, []tag) { +func (b *Redis) Handler(entry *logrus.Entry) (*entries, []tag) { file, line := GetStackCallFile(string(debug.Stack()), RedisSplit) b.Connection = file + ":" + line diff --git a/type_request.go b/type_request.go index dc3a10d..c0b60d2 100644 --- a/type_request.go +++ b/type_request.go @@ -27,15 +27,15 @@ type Request struct { Hostname string `json:"hostname,omitempty"` } -func (b Request) Init() { +func (b *Request) Init() { b.Hostname, _ = os.Hostname() } -func (b Request) BindType() string { +func (b *Request) BindType() string { return "request" } -func (b Request) Handler(entry *logrus.Entry) (*entries, []tag) { +func (b *Request) Handler(entry *logrus.Entry) (*entries, []tag) { b.Payload = make(map[string]interface{}) uuId := uuid.NewV4().String() diff --git a/type_schedule.go b/type_schedule.go index 0c5ea77..2af7c47 100644 --- a/type_schedule.go +++ b/type_schedule.go @@ -17,11 +17,11 @@ type Schedule struct { Hostname string `json:"hostname"` } -func (b Schedule) BindType() string { +func (b *Schedule) BindType() string { return "schedule" } -func (b Schedule) Handler(entry *logrus.Entry) (*entries, []tag) { +func (b *Schedule) Handler(entry *logrus.Entry) (*entries, []tag) { b.Command = entry.Message return &entries{ Uuid: uuid.NewV4().String(), diff --git a/type_tcp.go b/type_tcp.go index dd576dd..bd3bcc5 100644 --- a/type_tcp.go +++ b/type_tcp.go @@ -24,13 +24,13 @@ type Tcp struct { Hostname string `json:"hostname,omitempty"` } -func (b Tcp) BindType() string { +func (b *Tcp) BindType() string { return "tcp" } // Handler // logrus.WithFields(logrus.Fields{"type": "tcp","read": raw,"tags": []string{str}}).Debug(tpc_route) -func (b Tcp) Handler(entry *logrus.Entry) (*entries, []tag) { +func (b *Tcp) Handler(entry *logrus.Entry) (*entries, []tag) { ip, ok := entry.Data["ip"] if ok { b.IpAddress = ip.(string)