[TASK] more parallel

This commit is contained in:
Martin Geno 2017-06-24 13:17:47 +02:00
parent 9aa520b8f8
commit a0b30e6a9c
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
3 changed files with 17 additions and 1 deletions

View File

@ -10,6 +10,8 @@ import (
"github.com/genofire/logmania/database" "github.com/genofire/logmania/database"
"github.com/genofire/logmania/log" "github.com/genofire/logmania/log"
"github.com/genofire/logmania/notify" "github.com/genofire/logmania/notify"
logOutput "github.com/genofire/logmania/log/hook/output"
) )
// http.Handler for init network // http.Handler for init network
@ -79,6 +81,12 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
dbEntry := database.InsertEntry(token, &entry) dbEntry := database.InsertEntry(token, &entry)
if dbEntry != nil && h.Notify != nil { if dbEntry != nil && h.Notify != nil {
h.Notify.Send(dbEntry) h.Notify.Send(dbEntry)
} else {
l := logOutput.NewLogger()
e := log.New()
e.Text = "No notifier found"
e.Level = log.WarnLevel
l.Hook(e)
} }
} }
} }

View File

@ -3,6 +3,8 @@ package main
import ( import (
"github.com/genofire/logmania/database" "github.com/genofire/logmania/database"
"github.com/genofire/logmania/log" "github.com/genofire/logmania/log"
logOutput "github.com/genofire/logmania/log/hook/output"
) )
type SelfLogger struct { type SelfLogger struct {
@ -35,6 +37,12 @@ func (l *SelfLogger) Hook(e *log.Entry) {
dbEntry := database.InsertEntry("", e) dbEntry := database.InsertEntry("", e)
if dbEntry != nil && notifier != nil { if dbEntry != nil && notifier != nil {
notifier.Send(dbEntry) notifier.Send(dbEntry)
} else {
l := logOutput.NewLogger()
e := log.New()
e.Text = "No notifier found"
e.Level = log.WarnLevel
l.Hook(e)
} }
} }

View File

@ -28,7 +28,7 @@ func NotifyInit(config *lib.NotifyConfig) notify.Notifier {
func (n *Notifier) Send(entry *database.Entry) { func (n *Notifier) Send(entry *database.Entry) {
for _, item := range n.list { for _, item := range n.list {
item.Send(entry) go item.Send(entry)
} }
} }