mirror of
https://github.com/Xevion/r2park.git
synced 2025-12-05 23:15:56 -06:00
Use regex to filter which levels can match
This commit is contained in:
6
main.go
6
main.go
@@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"os"
|
||||
"os/signal"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
@@ -25,6 +25,7 @@ var (
|
||||
}
|
||||
db *redis.Client
|
||||
debugFlag = flag.Bool("debug", false, "Enable debug logging")
|
||||
levelPattern = regexp.MustCompile(`level=(error|fatal|panic|warning)`)
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -152,7 +153,8 @@ func Bot() {
|
||||
type OutputSplitter struct{}
|
||||
|
||||
func (splitter *OutputSplitter) Write(p []byte) (n int, err error) {
|
||||
if bytes.Contains(p, []byte("level=error")) {
|
||||
// Levels matched are contained within the OR'd group (error|fatal|panic|warning)
|
||||
if levelPattern.Match(p) {
|
||||
return os.Stderr.Write(p)
|
||||
}
|
||||
return os.Stdout.Write(p)
|
||||
|
||||
Reference in New Issue
Block a user