mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 13:18:01 +08:00
32 lines
583 B
Go
32 lines
583 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gogf/gf/net/ghttp"
|
|
"github.com/gogf/gf/os/glog"
|
|
"github.com/gogf/gf/text/gregex"
|
|
)
|
|
|
|
type MyWriter struct {
|
|
logger *glog.Logger
|
|
}
|
|
|
|
func (w *MyWriter) Write(p []byte) (n int, err error) {
|
|
s := string(p)
|
|
if gregex.IsMatchString(`\[(PANI|FATA)\]`, s) {
|
|
fmt.Println("SERIOUS ISSUE OCCURRED!! I'd better tell monitor in first time!")
|
|
ghttp.PostContent("http://monitor.mydomain.com", s)
|
|
}
|
|
return w.logger.Write(p)
|
|
}
|
|
|
|
func main() {
|
|
glog.SetWriter(&MyWriter{
|
|
logger: glog.New(),
|
|
})
|
|
glog.Debug("DEBUG")
|
|
glog.Fatal("FATAL ERROR")
|
|
|
|
}
|