mirror of
https://github.com/mariocandela/beelzebub.git
synced 2025-07-01 18:47:26 -04:00
Improve tracer
This commit is contained in:
45
tracer/tracer.go
Normal file
45
tracer/tracer.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package tracer
|
||||||
|
|
||||||
|
import (
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Tracer struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func Init() *Tracer {
|
||||||
|
return &Tracer{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tracer *Tracer) TraceEvent(event Event) {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"status": event.Status.String(),
|
||||||
|
"event": event,
|
||||||
|
}).Info("New Event")
|
||||||
|
}
|
||||||
|
|
||||||
|
type Event struct {
|
||||||
|
RemoteAddr string
|
||||||
|
Protocol string
|
||||||
|
Command string
|
||||||
|
Status Status
|
||||||
|
Msg string
|
||||||
|
ID string
|
||||||
|
Environ string
|
||||||
|
User string
|
||||||
|
Password string
|
||||||
|
Client string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Status int
|
||||||
|
|
||||||
|
const (
|
||||||
|
Start Status = iota
|
||||||
|
End
|
||||||
|
Stateless
|
||||||
|
Interaction
|
||||||
|
)
|
||||||
|
|
||||||
|
func (status Status) String() string {
|
||||||
|
return [...]string{"Start", "End", "Stateless", "Interaction"}[status]
|
||||||
|
}
|
Reference in New Issue
Block a user