mirror of
https://github.com/Xevion/r2park.git
synced 2025-12-06 09:16:03 -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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"flag"
|
"flag"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
@@ -25,6 +25,7 @@ var (
|
|||||||
}
|
}
|
||||||
db *redis.Client
|
db *redis.Client
|
||||||
debugFlag = flag.Bool("debug", false, "Enable debug logging")
|
debugFlag = flag.Bool("debug", false, "Enable debug logging")
|
||||||
|
levelPattern = regexp.MustCompile(`level=(error|fatal|panic|warning)`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -152,7 +153,8 @@ func Bot() {
|
|||||||
type OutputSplitter struct{}
|
type OutputSplitter struct{}
|
||||||
|
|
||||||
func (splitter *OutputSplitter) Write(p []byte) (n int, err error) {
|
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.Stderr.Write(p)
|
||||||
}
|
}
|
||||||
return os.Stdout.Write(p)
|
return os.Stdout.Write(p)
|
||||||
|
|||||||
Reference in New Issue
Block a user