forked from Elara6331/itd
Switch from zerolog to go.arsenm.dev/logger
This commit is contained in:
parent
81840d411d
commit
520c23b75b
12
calls.go
12
calls.go
@ -5,9 +5,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/godbus/dbus/v5"
|
"github.com/godbus/dbus/v5"
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
"go.arsenm.dev/itd/internal/utils"
|
"go.arsenm.dev/itd/internal/utils"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initCallNotifs(ctx context.Context, dev *infinitime.Device) error {
|
func initCallNotifs(ctx context.Context, dev *infinitime.Device) error {
|
||||||
@ -64,7 +64,7 @@ func initCallNotifs(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
// Get phone number from call object using method call connection
|
// Get phone number from call object using method call connection
|
||||||
phoneNum, err := getPhoneNum(conn, callObj)
|
phoneNum, err := getPhoneNum(conn, callObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error getting phone number")
|
log.Error("Error getting phone number").Err(err).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,24 +82,24 @@ func initCallNotifs(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
// Attempt to accept call
|
// Attempt to accept call
|
||||||
err = acceptCall(ctx, conn, callObj)
|
err = acceptCall(ctx, conn, callObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("Error accepting call")
|
log.Warn("Error accepting call").Err(err).Send()
|
||||||
}
|
}
|
||||||
case infinitime.CallStatusDeclined:
|
case infinitime.CallStatusDeclined:
|
||||||
// Attempt to decline call
|
// Attempt to decline call
|
||||||
err = declineCall(ctx, conn, callObj)
|
err = declineCall(ctx, conn, callObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("Error declining call")
|
log.Warn("Error declining call").Err(err).Send()
|
||||||
}
|
}
|
||||||
case infinitime.CallStatusMuted:
|
case infinitime.CallStatusMuted:
|
||||||
// Warn about unimplemented muting
|
// Warn about unimplemented muting
|
||||||
log.Warn().Msg("Muting calls is not implemented")
|
log.Warn("Muting calls is not implemented").Send()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Info().Msg("Relaying calls to InfiniTime")
|
log.Info("Relaying calls to InfiniTime").Send()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cheggaaa/pb/v3"
|
"github.com/cheggaaa/pb/v3"
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"go.arsenm.dev/itd/api"
|
"go.arsenm.dev/itd/api"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fwUpgrade(c *cli.Context) error {
|
func fwUpgrade(c *cli.Context) error {
|
||||||
|
@ -8,9 +8,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"go.arsenm.dev/itd/api"
|
"go.arsenm.dev/itd/api"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var client *api.Client
|
var client *api.Client
|
||||||
@ -296,7 +296,7 @@ func main() {
|
|||||||
|
|
||||||
err := app.RunContext(ctx, os.Args)
|
err := app.RunContext(ctx, os.Args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Error while running app")
|
log.Fatal("Error while running app").Err(err).Send()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
config.go
10
config.go
@ -9,8 +9,8 @@ import (
|
|||||||
"github.com/knadh/koanf/providers/confmap"
|
"github.com/knadh/koanf/providers/confmap"
|
||||||
"github.com/knadh/koanf/providers/env"
|
"github.com/knadh/koanf/providers/env"
|
||||||
"github.com/knadh/koanf/providers/file"
|
"github.com/knadh/koanf/providers/file"
|
||||||
"github.com/rs/zerolog"
|
"go.arsenm.dev/logger"
|
||||||
"github.com/rs/zerolog/log"
|
"go.arsenm.dev/logger/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cfgDir string
|
var cfgDir string
|
||||||
@ -19,7 +19,7 @@ func init() {
|
|||||||
etcPath := "/etc/itd.toml"
|
etcPath := "/etc/itd.toml"
|
||||||
|
|
||||||
// Set up logger
|
// Set up logger
|
||||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
log.Logger = logger.NewPretty(os.Stderr)
|
||||||
|
|
||||||
// Get user's configuration directory
|
// Get user's configuration directory
|
||||||
userCfgDir, err := os.UserConfigDir()
|
userCfgDir, err := os.UserConfigDir()
|
||||||
@ -67,7 +67,7 @@ func loadAndwatchCfgFile(filename string) {
|
|||||||
provider := file.Provider(filename)
|
provider := file.Provider(filename)
|
||||||
|
|
||||||
if cfgError := k.Load(provider, toml.Parser()); cfgError != nil {
|
if cfgError := k.Load(provider, toml.Parser()); cfgError != nil {
|
||||||
log.Warn().Str("filename", filename).Err(cfgError).Msg("Error while trying to read config file")
|
log.Warn("Error while trying to read config file").Str("filename", filename).Err(cfgError).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch for changes and reload when detected
|
// Watch for changes and reload when detected
|
||||||
@ -77,7 +77,7 @@ func loadAndwatchCfgFile(filename string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cfgError := k.Load(provider, toml.Parser()); cfgError != nil {
|
if cfgError := k.Load(provider, toml.Parser()); cfgError != nil {
|
||||||
log.Warn().Str("filename", filename).Err(cfgError).Msg("Error while trying to read config file")
|
log.Warn("Error while trying to read config file").Str("filename", filename).Err(cfgError).Send()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
5
go.mod
5
go.mod
@ -16,7 +16,8 @@ require (
|
|||||||
github.com/rs/zerolog v1.28.0
|
github.com/rs/zerolog v1.28.0
|
||||||
github.com/urfave/cli/v2 v2.23.7
|
github.com/urfave/cli/v2 v2.23.7
|
||||||
go.arsenm.dev/drpc v0.0.0-20230104221210-aa7525743d98
|
go.arsenm.dev/drpc v0.0.0-20230104221210-aa7525743d98
|
||||||
go.arsenm.dev/infinitime v0.0.0-20221122225335-2da80044b34a
|
go.arsenm.dev/infinitime v0.0.0-20230104230015-512d48bc2469
|
||||||
|
go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df
|
||||||
golang.org/x/text v0.5.0
|
golang.org/x/text v0.5.0
|
||||||
google.golang.org/protobuf v1.28.1
|
google.golang.org/protobuf v1.28.1
|
||||||
modernc.org/sqlite v1.20.1
|
modernc.org/sqlite v1.20.1
|
||||||
@ -43,6 +44,7 @@ require (
|
|||||||
github.com/go-text/typesetting v0.0.0-20221219135543-5d0d724ee181 // indirect
|
github.com/go-text/typesetting v0.0.0-20221219135543-5d0d724ee181 // indirect
|
||||||
github.com/goki/freetype v0.0.0-20220119013949-7a161fd3728c // indirect
|
github.com/goki/freetype v0.0.0-20220119013949-7a161fd3728c // indirect
|
||||||
github.com/google/uuid v1.3.0 // indirect
|
github.com/google/uuid v1.3.0 // indirect
|
||||||
|
github.com/gookit/color v1.5.1 // indirect
|
||||||
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
||||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||||
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
|
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
|
||||||
@ -64,6 +66,7 @@ require (
|
|||||||
github.com/stretchr/testify v1.8.1 // indirect
|
github.com/stretchr/testify v1.8.1 // indirect
|
||||||
github.com/tevino/abool v1.2.0 // indirect
|
github.com/tevino/abool v1.2.0 // indirect
|
||||||
github.com/x448/float16 v0.8.4 // indirect
|
github.com/x448/float16 v0.8.4 // indirect
|
||||||
|
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||||
github.com/yuin/goldmark v1.5.3 // indirect
|
github.com/yuin/goldmark v1.5.3 // indirect
|
||||||
github.com/zeebo/errs v1.3.0 // indirect
|
github.com/zeebo/errs v1.3.0 // indirect
|
||||||
|
15
go.sum
15
go.sum
@ -247,6 +247,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
|||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
|
github.com/gookit/color v1.5.1 h1:Vjg2VEcdHpwq+oY63s/ksHrgJYCTo0bwWvmmYWdE9fQ=
|
||||||
|
github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHPaqKM=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20211219123610-ec9572f70e60/go.mod h1:cz9oNYuRUWGdHmLF2IodMLkAhcPtXeULvcBNagUrxTI=
|
github.com/gopherjs/gopherjs v0.0.0-20211219123610-ec9572f70e60/go.mod h1:cz9oNYuRUWGdHmLF2IodMLkAhcPtXeULvcBNagUrxTI=
|
||||||
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
|
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
|
||||||
@ -446,9 +448,7 @@ github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
|
|||||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
|
||||||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc=
|
|
||||||
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
|
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
|
||||||
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
@ -498,6 +498,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
|||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
@ -512,6 +513,8 @@ github.com/urfave/cli/v2 v2.23.7/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6f
|
|||||||
github.com/wagslane/go-password-validator v0.3.0/go.mod h1:TI1XJ6T5fRdRnHqHt14pvy1tNVnrwe7m3/f1f2fDphQ=
|
github.com/wagslane/go-password-validator v0.3.0/go.mod h1:TI1XJ6T5fRdRnHqHt14pvy1tNVnrwe7m3/f1f2fDphQ=
|
||||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||||
|
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
|
||||||
|
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
@ -529,8 +532,10 @@ github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs=
|
|||||||
github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
|
github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
|
||||||
go.arsenm.dev/drpc v0.0.0-20230104221210-aa7525743d98 h1:Tt/05IEOeIEfovj8YLxDaZz+SP8eR1uPLtcgD5Pf4EI=
|
go.arsenm.dev/drpc v0.0.0-20230104221210-aa7525743d98 h1:Tt/05IEOeIEfovj8YLxDaZz+SP8eR1uPLtcgD5Pf4EI=
|
||||||
go.arsenm.dev/drpc v0.0.0-20230104221210-aa7525743d98/go.mod h1:K5cFls42m5q1RIphTVojRdXLaoCknq/kBqQt8Ow3XuA=
|
go.arsenm.dev/drpc v0.0.0-20230104221210-aa7525743d98/go.mod h1:K5cFls42m5q1RIphTVojRdXLaoCknq/kBqQt8Ow3XuA=
|
||||||
go.arsenm.dev/infinitime v0.0.0-20221122225335-2da80044b34a h1:4XmKIO0udIwVS9wqoi4hq76y3+X0MeV/GRMo2/01xSU=
|
go.arsenm.dev/infinitime v0.0.0-20230104230015-512d48bc2469 h1:LsJHg+8rQSYnTE1sSCjBCACxUUVMZIOQani8J6wF2/E=
|
||||||
go.arsenm.dev/infinitime v0.0.0-20221122225335-2da80044b34a/go.mod h1:K3NJ6fyPv5qqHUedB3MccKOE0whJMJZ80l/yTzzTrgc=
|
go.arsenm.dev/infinitime v0.0.0-20230104230015-512d48bc2469/go.mod h1:scUyDmLmCHn6CanGbau8yjTjzyhUbLJcsjmDCCKMIII=
|
||||||
|
go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df h1:8mBHvEe7BJmpOeKSMA5YLqrGo9dCpePocTeR0C1+/2w=
|
||||||
|
go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df/go.mod h1:RV2qydKDdoyaRkhAq8JEGvojR8eJ6bjq5WnSIlH7gYw=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
|
go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
||||||
@ -558,7 +563,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
@ -827,7 +831,6 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
|
|||||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
|
||||||
golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.4.0 h1:7mTAgkunk3fr4GAloyyCasadO6h9zSsQZbwvcaIciV4=
|
golang.org/x/tools v0.4.0 h1:7mTAgkunk3fr4GAloyyCasadO6h9zSsQZbwvcaIciV4=
|
||||||
|
34
main.go
34
main.go
@ -32,9 +32,9 @@ import (
|
|||||||
"github.com/gen2brain/dlgs"
|
"github.com/gen2brain/dlgs"
|
||||||
"github.com/knadh/koanf"
|
"github.com/knadh/koanf"
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
"github.com/rs/zerolog"
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
|
"go.arsenm.dev/logger"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var k = koanf.New(".")
|
var k = koanf.New(".")
|
||||||
@ -54,9 +54,9 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
level, err := zerolog.ParseLevel(k.String("logging.level"))
|
level, err := logger.ParseLogLevel(k.String("logging.level"))
|
||||||
if err != nil || level == zerolog.NoLevel {
|
if err != nil {
|
||||||
level = zerolog.InfoLevel
|
level = logger.LogLevelInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize infinitime library
|
// Initialize infinitime library
|
||||||
@ -93,7 +93,7 @@ func main() {
|
|||||||
// Connect to InfiniTime with default options
|
// Connect to InfiniTime with default options
|
||||||
dev, err := infinitime.Connect(ctx, opts)
|
dev, err := infinitime.Connect(ctx, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Error connecting to InfiniTime")
|
log.Fatal("Error connecting to InfiniTime").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// When InfiniTime reconnects
|
// When InfiniTime reconnects
|
||||||
@ -124,67 +124,67 @@ func main() {
|
|||||||
// Get firmware version
|
// Get firmware version
|
||||||
ver, err := dev.Version()
|
ver, err := dev.Version()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error getting firmware version")
|
log.Error("Error getting firmware version").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log connection
|
// Log connection
|
||||||
log.Info().Str("version", ver).Msg("Connected to InfiniTime")
|
log.Info("Connected to InfiniTime").Str("version", ver).Send()
|
||||||
|
|
||||||
// If config specifies to notify on connect
|
// If config specifies to notify on connect
|
||||||
if k.Bool("on.connect.notify") {
|
if k.Bool("on.connect.notify") {
|
||||||
// Send notification to InfiniTime
|
// Send notification to InfiniTime
|
||||||
err = dev.Notify("itd", "Successfully connected")
|
err = dev.Notify("itd", "Successfully connected")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error sending notification to InfiniTime")
|
log.Error("Error sending notification to InfiniTime").Err(err).Send()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set time to current time
|
// Set time to current time
|
||||||
err = dev.SetTime(time.Now())
|
err = dev.SetTime(time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error setting current time on connected InfiniTime")
|
log.Error("Error setting current time on connected InfiniTime").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize music controls
|
// Initialize music controls
|
||||||
err = initMusicCtrl(ctx, dev)
|
err = initMusicCtrl(ctx, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error initializing music control")
|
log.Error("Error initializing music control").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start control socket
|
// Start control socket
|
||||||
err = initCallNotifs(ctx, dev)
|
err = initCallNotifs(ctx, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error initializing call notifications")
|
log.Error("Error initializing call notifications").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize notification relay
|
// Initialize notification relay
|
||||||
err = initNotifRelay(ctx, dev)
|
err = initNotifRelay(ctx, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error initializing notification relay")
|
log.Error("Error initializing notification relay").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializa weather
|
// Initializa weather
|
||||||
err = initWeather(ctx, dev)
|
err = initWeather(ctx, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error initializing weather")
|
log.Error("Error initializing weather").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize metrics collection
|
// Initialize metrics collection
|
||||||
err = initMetrics(ctx, dev)
|
err = initMetrics(ctx, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error intializing metrics collection")
|
log.Error("Error intializing metrics collection").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize metrics collection
|
// Initialize metrics collection
|
||||||
err = initPureMaps(ctx, dev)
|
err = initPureMaps(ctx, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error intializing puremaps integration")
|
log.Error("Error intializing puremaps integration").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start control socket
|
// Start control socket
|
||||||
err = startSocket(ctx, dev)
|
err = startSocket(ctx, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error starting socket")
|
log.Error("Error starting socket").Err(err).Send()
|
||||||
}
|
}
|
||||||
// Block forever
|
// Block forever
|
||||||
select {}
|
select {}
|
||||||
|
26
maps.go
26
maps.go
@ -5,9 +5,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/godbus/dbus/v5"
|
"github.com/godbus/dbus/v5"
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
"go.arsenm.dev/itd/internal/utils"
|
"go.arsenm.dev/itd/internal/utils"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -55,7 +55,7 @@ func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
navigator = conn.Object("io.github.rinigus.PureMaps", "/io/github/rinigus/PureMaps/navigator")
|
navigator = conn.Object("io.github.rinigus.PureMaps", "/io/github/rinigus/PureMaps/navigator")
|
||||||
err = setAll(navigator, dev)
|
err = setAll(navigator, dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error setting all navigation fields")
|
log.Error("Error setting all navigation fields").Err(err).Send()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
var member string
|
var member string
|
||||||
err = sig.Headers[dbus.FieldMember].Store(&member)
|
err = sig.Headers[dbus.FieldMember].Store(&member)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error getting dbus member field")
|
log.Error("Error getting dbus member field").Err(err).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().Str("member", member).Msg("Signal received from PureMaps navigator")
|
log.Debug("Signal received from PureMaps navigator").Str("member", member).Send()
|
||||||
|
|
||||||
// The object must be retrieved in this loop in case PureMaps was not
|
// The object must be retrieved in this loop in case PureMaps was not
|
||||||
// open at the time ITD was started.
|
// open at the time ITD was started.
|
||||||
@ -93,52 +93,52 @@ func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
var icon string
|
var icon string
|
||||||
err = navigator.StoreProperty(iconProperty, &icon)
|
err = navigator.StoreProperty(iconProperty, &icon)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("property", member).Msg("Error getting property")
|
log.Error("Error getting property").Err(err).Str("property", member).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dev.Navigation.SetFlag(infinitime.NavFlag(icon))
|
err = dev.Navigation.SetFlag(infinitime.NavFlag(icon))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("property", member).Msg("Error setting flag")
|
log.Error("Error setting flag").Err(err).Str("property", member).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case "narrative":
|
case "narrative":
|
||||||
var narrative string
|
var narrative string
|
||||||
err = navigator.StoreProperty(narrativeProperty, &narrative)
|
err = navigator.StoreProperty(narrativeProperty, &narrative)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("property", member).Msg("Error getting property")
|
log.Error("Error getting property").Err(err).Str("property", member).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dev.Navigation.SetNarrative(narrative)
|
err = dev.Navigation.SetNarrative(narrative)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("property", member).Msg("Error setting flag")
|
log.Error("Error setting flag").Err(err).Str("property", member).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case "manDist":
|
case "manDist":
|
||||||
var manDist string
|
var manDist string
|
||||||
err = navigator.StoreProperty(manDistProperty, &manDist)
|
err = navigator.StoreProperty(manDistProperty, &manDist)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("property", member).Msg("Error getting property")
|
log.Error("Error getting property").Err(err).Str("property", member).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dev.Navigation.SetManDist(manDist)
|
err = dev.Navigation.SetManDist(manDist)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("property", member).Msg("Error setting flag")
|
log.Error("Error setting flag").Err(err).Str("property", member).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case "progress":
|
case "progress":
|
||||||
var progress int32
|
var progress int32
|
||||||
err = navigator.StoreProperty(progressProperty, &progress)
|
err = navigator.StoreProperty(progressProperty, &progress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("property", member).Msg("Error getting property")
|
log.Error("Error getting property").Err(err).Str("property", member).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dev.Navigation.SetProgress(uint8(progress))
|
err = dev.Navigation.SetProgress(uint8(progress))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("property", member).Msg("Error setting flag")
|
log.Error("Error setting flag").Err(err).Str("property", member).Send()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
if exists {
|
if exists {
|
||||||
log.Info().Msg("Sending PureMaps data to InfiniTime")
|
log.Info("Sending PureMaps data to InfiniTime").Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ func initMetrics(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info().Msg("Initialized metrics collection")
|
log.Info("Initialized metrics collection").Send()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
4
music.go
4
music.go
@ -21,10 +21,10 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
"go.arsenm.dev/itd/mpris"
|
"go.arsenm.dev/itd/mpris"
|
||||||
"go.arsenm.dev/itd/translit"
|
"go.arsenm.dev/itd/translit"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initMusicCtrl(ctx context.Context, dev *infinitime.Device) error {
|
func initMusicCtrl(ctx context.Context, dev *infinitime.Device) error {
|
||||||
@ -76,7 +76,7 @@ func initMusicCtrl(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// Log completed initialization
|
// Log completed initialization
|
||||||
log.Info().Msg("Initialized InfiniTime music controls")
|
log.Info("Initialized InfiniTime music controls").Send()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/godbus/dbus/v5"
|
"github.com/godbus/dbus/v5"
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
"go.arsenm.dev/itd/internal/utils"
|
"go.arsenm.dev/itd/internal/utils"
|
||||||
"go.arsenm.dev/itd/translit"
|
"go.arsenm.dev/itd/translit"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initNotifRelay(ctx context.Context, dev *infinitime.Device) error {
|
func initNotifRelay(ctx context.Context, dev *infinitime.Device) error {
|
||||||
@ -94,7 +94,7 @@ func initNotifRelay(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Info().Msg("Relaying notifications to InfiniTime")
|
log.Info("Relaying notifications to InfiniTime").Send()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"go.arsenm.dev/drpc/muxserver"
|
"go.arsenm.dev/drpc/muxserver"
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
"go.arsenm.dev/infinitime/blefs"
|
"go.arsenm.dev/infinitime/blefs"
|
||||||
"go.arsenm.dev/itd/internal/rpc"
|
"go.arsenm.dev/itd/internal/rpc"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
"storj.io/drpc/drpcmux"
|
"storj.io/drpc/drpcmux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ func startSocket(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
|
|
||||||
fs, err := dev.FS()
|
fs, err := dev.FS()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("Error getting BLE filesystem")
|
log.Warn("Error getting BLE filesystem").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
mux := drpcmux.New()
|
mux := drpcmux.New()
|
||||||
@ -80,7 +80,7 @@ func startSocket(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
go muxserver.New(mux).Serve(ctx, ln)
|
go muxserver.New(mux).Serve(ctx, ln)
|
||||||
|
|
||||||
// Log socket start
|
// Log socket start
|
||||||
log.Info().Str("path", k.String("socket.path")).Msg("Started control socket")
|
log.Info("Started control socket").Str("path", k.String("socket.path")).Send()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ func (fs *FS) updateFS() {
|
|||||||
// Get new FS
|
// Get new FS
|
||||||
newFS, err := fs.dev.FS()
|
newFS, err := fs.dev.FS()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("Error updating BLE filesystem")
|
log.Warn("Error updating BLE filesystem").Err(err).Send()
|
||||||
} else {
|
} else {
|
||||||
// Set FS pointer to new FS
|
// Set FS pointer to new FS
|
||||||
fs.fs = newFS
|
fs.fs = newFS
|
||||||
|
16
weather.go
16
weather.go
@ -11,9 +11,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
"go.arsenm.dev/infinitime/weather"
|
"go.arsenm.dev/infinitime/weather"
|
||||||
|
"go.arsenm.dev/logger/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// METResponse represents a response from
|
// METResponse represents a response from
|
||||||
@ -79,7 +79,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
// Attempt to get weather
|
// Attempt to get weather
|
||||||
data, err := getWeather(ctx, lat, lon)
|
data, err := getWeather(ctx, lat, lon)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("Error getting weather data")
|
log.Warn("Error getting weather data").Err(err).Send()
|
||||||
// Wait 15 minutes before retrying
|
// Wait 15 minutes before retrying
|
||||||
time.Sleep(15 * time.Minute)
|
time.Sleep(15 * time.Minute)
|
||||||
continue
|
continue
|
||||||
@ -99,7 +99,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
DewPoint: int16(round(currentData.DewPoint)),
|
DewPoint: int16(round(currentData.DewPoint)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error adding temperature event")
|
log.Error("Error adding temperature event").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add precipitation event
|
// Add precipitation event
|
||||||
@ -112,7 +112,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
Amount: uint8(round(current.Data.NextHour.Details.PrecipitationAmount)),
|
Amount: uint8(round(current.Data.NextHour.Details.PrecipitationAmount)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error adding precipitation event")
|
log.Error("Error adding precipitation event").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add wind event
|
// Add wind event
|
||||||
@ -127,7 +127,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
DirectionMax: uint8(round(currentData.WindDirection)),
|
DirectionMax: uint8(round(currentData.WindDirection)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error adding wind event")
|
log.Error("Error adding wind event").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add cloud event
|
// Add cloud event
|
||||||
@ -139,7 +139,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
Amount: uint8(round(currentData.CloudAreaFraction)),
|
Amount: uint8(round(currentData.CloudAreaFraction)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error adding clouds event")
|
log.Error("Error adding clouds event").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add humidity event
|
// Add humidity event
|
||||||
@ -151,7 +151,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
Humidity: uint8(round(currentData.RelativeHumidity)),
|
Humidity: uint8(round(currentData.RelativeHumidity)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error adding humidity event")
|
log.Error("Error adding humidity event").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add pressure event
|
// Add pressure event
|
||||||
@ -163,7 +163,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
Pressure: int16(round(currentData.AirPressure)),
|
Pressure: int16(round(currentData.AirPressure)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Error adding pressure event")
|
log.Error("Error adding pressure event").Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset timer to 1 hour
|
// Reset timer to 1 hour
|
||||||
|
Loading…
Reference in New Issue
Block a user