Update mautrix-go and switch to zerolog

This commit is contained in:
Tulir Asokan
2023-02-26 21:50:16 +02:00
parent cace8b5939
commit 77b230f4d8
7 changed files with 53 additions and 40 deletions

17
main.go
View File

@@ -18,8 +18,13 @@ package main
import (
_ "embed"
"fmt"
"runtime"
"strings"
"sync"
"github.com/rs/zerolog"
"maunium.net/go/mautrix/bridge"
"maunium.net/go/mautrix/bridge/commands"
"maunium.net/go/mautrix/id"
@@ -93,7 +98,17 @@ func (br *DiscordBridge) Init() {
br.RegisterCommands()
br.DB = database.New(br.Bridge.DB, br.Log.Sub("Database"))
discordLog = br.Log.Sub("Discord")
discordLog = br.ZLog.With().Str("component", "discordgo").Logger()
// TODO move this to mautrix-go?
zerolog.CallerMarshalFunc = func(pc uintptr, file string, line int) string {
files := strings.Split(file, "/")
file = files[len(files)-1]
name := runtime.FuncForPC(pc).Name()
fns := strings.Split(name, ".")
name = fns[len(fns)-1]
return fmt.Sprintf("%s:%d:%s()", file, line, name)
}
}
func (br *DiscordBridge) Start() {