add logtr.sosf for sos straight to specific matrix

This commit is contained in:
bel
2022-01-17 18:40:31 -07:00
parent 73ccc22fd5
commit a38a627f5a
6 changed files with 73 additions and 24 deletions

View File

@@ -10,10 +10,21 @@ import (
"time"
)
type Matrix struct {
ReceiveEnabled bool
Mock bool
Homeserver string
Username string
Token string
Device string
Room string
}
type Config struct {
Log struct {
Path string
Level logtr.Level
Path string
Level logtr.Level
SOSMatrix Matrix
}
Interval struct {
Input Duration
@@ -49,15 +60,7 @@ type Config struct {
Clients map[string]Client
Storage []string
Message struct {
Matrix struct {
ReceiveEnabled bool
Mock bool
Homeserver string
Username string
Token string
Device string
Room string
}
Matrix Matrix
}
Once bool
Brokers struct {
@@ -117,7 +120,7 @@ func AllStates() []State {
return states
}
func Refresh() error {
func Refresh(soser func() logtr.SOSer) error {
b, err := ioutil.ReadFile(configPath())
if err != nil {
return err
@@ -132,6 +135,9 @@ func Refresh() error {
live.db.Close()
}
live = c
if soser != nil {
logtr.SetSOSer(soser())
}
return nil
}
@@ -145,7 +151,7 @@ func Set(other Config) {
return
}
ioutil.WriteFile(configPath(), b, os.ModePerm)
Refresh()
Refresh(nil)
}
func (c *Config) DB() storage.DB {