[TASK] more parallel
This commit is contained in:
parent
9aa520b8f8
commit
a0b30e6a9c
|
@ -10,6 +10,8 @@ import (
|
|||
"github.com/genofire/logmania/database"
|
||||
"github.com/genofire/logmania/log"
|
||||
"github.com/genofire/logmania/notify"
|
||||
|
||||
logOutput "github.com/genofire/logmania/log/hook/output"
|
||||
)
|
||||
|
||||
// http.Handler for init network
|
||||
|
@ -79,6 +81,12 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
dbEntry := database.InsertEntry(token, &entry)
|
||||
if dbEntry != nil && h.Notify != nil {
|
||||
h.Notify.Send(dbEntry)
|
||||
} else {
|
||||
l := logOutput.NewLogger()
|
||||
e := log.New()
|
||||
e.Text = "No notifier found"
|
||||
e.Level = log.WarnLevel
|
||||
l.Hook(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package main
|
|||
import (
|
||||
"github.com/genofire/logmania/database"
|
||||
"github.com/genofire/logmania/log"
|
||||
|
||||
logOutput "github.com/genofire/logmania/log/hook/output"
|
||||
)
|
||||
|
||||
type SelfLogger struct {
|
||||
|
@ -35,6 +37,12 @@ func (l *SelfLogger) Hook(e *log.Entry) {
|
|||
dbEntry := database.InsertEntry("", e)
|
||||
if dbEntry != nil && notifier != nil {
|
||||
notifier.Send(dbEntry)
|
||||
} else {
|
||||
l := logOutput.NewLogger()
|
||||
e := log.New()
|
||||
e.Text = "No notifier found"
|
||||
e.Level = log.WarnLevel
|
||||
l.Hook(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ func NotifyInit(config *lib.NotifyConfig) notify.Notifier {
|
|||
|
||||
func (n *Notifier) Send(entry *database.Entry) {
|
||||
for _, item := range n.list {
|
||||
item.Send(entry)
|
||||
go item.Send(entry)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue