[TASK] start of notify
This commit is contained in:
parent
f94f35c657
commit
5f74be54e6
|
@ -32,7 +32,10 @@ func (l *SelfLogger) Hook(e *log.Entry) {
|
|||
l.lastMsg = e.Text
|
||||
l.lastTime = 1
|
||||
}
|
||||
database.InsertEntry("", e)
|
||||
dbEntry := database.InsertEntry("", e)
|
||||
if dbEntry != nil && notifier != nil {
|
||||
notifier.Send(dbEntry)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *SelfLogger) Close() {
|
||||
|
|
|
@ -17,6 +17,3 @@ type NotifyInit func(*lib.NotifyConfig) Notifier
|
|||
func AddNotifier(n NotifyInit) {
|
||||
NotifyRegister = append(NotifyRegister, n)
|
||||
}
|
||||
|
||||
func Start(config *lib.NotifyConfig) {
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@ package xmpp
|
|||
|
||||
import "github.com/genofire/logmania/database"
|
||||
|
||||
func FormatEntry(e *database.Entry) string {
|
||||
func formatEntry(e *database.Entry) string {
|
||||
return e.Text
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ func NotifyInit(config *lib.NotifyConfig) notify.Notifier {
|
|||
func (n *Notifier) Send(e *database.Entry) {
|
||||
users := database.UserByApplication(e.ApplicationID)
|
||||
for _, user := range users {
|
||||
if user.NotifyXMPP && user.NotifyAfterLoglevel <= log.LogLevel(e.Level) {
|
||||
n.client.SendHtml(xmpp.Chat{Remote: user.XMPP, Type: "chat", Text: FormatEntry(e)})
|
||||
if user.NotifyXMPP && log.LogLevel(e.Level) >= user.NotifyAfterLoglevel {
|
||||
n.client.SendHtml(xmpp.Chat{Remote: user.XMPP, Type: "chat", Text: formatEntry(e)})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue