Switch from zerolog to go.arsenm.dev/logger
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
81840d411d
commit
520c23b75b
12
calls.go
12
calls.go
@ -5,9 +5,9 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/godbus/dbus/v5"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/itd/internal/utils"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
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
|
||||
phoneNum, err := getPhoneNum(conn, callObj)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error getting phone number")
|
||||
log.Error("Error getting phone number").Err(err).Send()
|
||||
continue
|
||||
}
|
||||
|
||||
@ -82,24 +82,24 @@ func initCallNotifs(ctx context.Context, dev *infinitime.Device) error {
|
||||
// Attempt to accept call
|
||||
err = acceptCall(ctx, conn, callObj)
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Msg("Error accepting call")
|
||||
log.Warn("Error accepting call").Err(err).Send()
|
||||
}
|
||||
case infinitime.CallStatusDeclined:
|
||||
// Attempt to decline call
|
||||
err = declineCall(ctx, conn, callObj)
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Msg("Error declining call")
|
||||
log.Warn("Error declining call").Err(err).Send()
|
||||
}
|
||||
case infinitime.CallStatusMuted:
|
||||
// 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
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cheggaaa/pb/v3"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
"go.arsenm.dev/itd/api"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
func fwUpgrade(c *cli.Context) error {
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
"go.arsenm.dev/itd/api"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
var client *api.Client
|
||||
@ -296,7 +296,7 @@ func main() {
|
||||
|
||||
err := app.RunContext(ctx, os.Args)
|
||||
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/env"
|
||||
"github.com/knadh/koanf/providers/file"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/logger"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
var cfgDir string
|
||||
@ -19,7 +19,7 @@ func init() {
|
||||
etcPath := "/etc/itd.toml"
|
||||
|
||||
// Set up logger
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||
log.Logger = logger.NewPretty(os.Stderr)
|
||||
|
||||
// Get user's configuration directory
|
||||
userCfgDir, err := os.UserConfigDir()
|
||||
@ -67,7 +67,7 @@ func loadAndwatchCfgFile(filename string) {
|
||||
provider := file.Provider(filename)
|
||||
|
||||
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
|
||||
@ -77,7 +77,7 @@ func loadAndwatchCfgFile(filename string) {
|
||||
}
|
||||
|
||||
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/urfave/cli/v2 v2.23.7
|
||||
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
|
||||
google.golang.org/protobuf v1.28.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/goki/freetype v0.0.0-20220119013949-7a161fd3728c // 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/hashicorp/yamux v0.1.1 // 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/tevino/abool v1.2.0 // 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/yuin/goldmark v1.5.3 // 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/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/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-20211219123610-ec9572f70e60/go.mod h1:cz9oNYuRUWGdHmLF2IodMLkAhcPtXeULvcBNagUrxTI=
|
||||
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/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/rs/xid v1.3.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/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
||||
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.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.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.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
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/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||
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/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
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=
|
||||
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/infinitime v0.0.0-20221122225335-2da80044b34a h1:4XmKIO0udIwVS9wqoi4hq76y3+X0MeV/GRMo2/01xSU=
|
||||
go.arsenm.dev/infinitime v0.0.0-20221122225335-2da80044b34a/go.mod h1:K3NJ6fyPv5qqHUedB3MccKOE0whJMJZ80l/yTzzTrgc=
|
||||
go.arsenm.dev/infinitime v0.0.0-20230104230015-512d48bc2469 h1:LsJHg+8rQSYnTE1sSCjBCACxUUVMZIOQani8J6wF2/E=
|
||||
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.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
|
||||
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-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-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-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
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.2/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.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
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/knadh/koanf"
|
||||
"github.com/mattn/go-isatty"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/logger"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
var k = koanf.New(".")
|
||||
@ -54,9 +54,9 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
level, err := zerolog.ParseLevel(k.String("logging.level"))
|
||||
if err != nil || level == zerolog.NoLevel {
|
||||
level = zerolog.InfoLevel
|
||||
level, err := logger.ParseLogLevel(k.String("logging.level"))
|
||||
if err != nil {
|
||||
level = logger.LogLevelInfo
|
||||
}
|
||||
|
||||
// Initialize infinitime library
|
||||
@ -93,7 +93,7 @@ func main() {
|
||||
// Connect to InfiniTime with default options
|
||||
dev, err := infinitime.Connect(ctx, opts)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error connecting to InfiniTime")
|
||||
log.Fatal("Error connecting to InfiniTime").Err(err).Send()
|
||||
}
|
||||
|
||||
// When InfiniTime reconnects
|
||||
@ -124,67 +124,67 @@ func main() {
|
||||
// Get firmware version
|
||||
ver, err := dev.Version()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error getting firmware version")
|
||||
log.Error("Error getting firmware version").Err(err).Send()
|
||||
}
|
||||
|
||||
// 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 k.Bool("on.connect.notify") {
|
||||
// Send notification to InfiniTime
|
||||
err = dev.Notify("itd", "Successfully connected")
|
||||
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
|
||||
err = dev.SetTime(time.Now())
|
||||
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
|
||||
err = initMusicCtrl(ctx, dev)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error initializing music control")
|
||||
log.Error("Error initializing music control").Err(err).Send()
|
||||
}
|
||||
|
||||
// Start control socket
|
||||
err = initCallNotifs(ctx, dev)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error initializing call notifications")
|
||||
log.Error("Error initializing call notifications").Err(err).Send()
|
||||
}
|
||||
|
||||
// Initialize notification relay
|
||||
err = initNotifRelay(ctx, dev)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error initializing notification relay")
|
||||
log.Error("Error initializing notification relay").Err(err).Send()
|
||||
}
|
||||
|
||||
// Initializa weather
|
||||
err = initWeather(ctx, dev)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error initializing weather")
|
||||
log.Error("Error initializing weather").Err(err).Send()
|
||||
}
|
||||
|
||||
// Initialize metrics collection
|
||||
err = initMetrics(ctx, dev)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error intializing metrics collection")
|
||||
log.Error("Error intializing metrics collection").Err(err).Send()
|
||||
}
|
||||
|
||||
// Initialize metrics collection
|
||||
err = initPureMaps(ctx, dev)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error intializing puremaps integration")
|
||||
log.Error("Error intializing puremaps integration").Err(err).Send()
|
||||
}
|
||||
|
||||
// Start control socket
|
||||
err = startSocket(ctx, dev)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error starting socket")
|
||||
log.Error("Error starting socket").Err(err).Send()
|
||||
}
|
||||
// Block forever
|
||||
select {}
|
||||
|
26
maps.go
26
maps.go
@ -5,9 +5,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/godbus/dbus/v5"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/itd/internal/utils"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
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")
|
||||
err = setAll(navigator, dev)
|
||||
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
|
||||
err = sig.Headers[dbus.FieldMember].Store(&member)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error getting dbus member field")
|
||||
log.Error("Error getting dbus member field").Err(err).Send()
|
||||
continue
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
|
||||
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
|
||||
// open at the time ITD was started.
|
||||
@ -93,52 +93,52 @@ func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
|
||||
var icon string
|
||||
err = navigator.StoreProperty(iconProperty, &icon)
|
||||
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
|
||||
}
|
||||
|
||||
err = dev.Navigation.SetFlag(infinitime.NavFlag(icon))
|
||||
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
|
||||
}
|
||||
case "narrative":
|
||||
var narrative string
|
||||
err = navigator.StoreProperty(narrativeProperty, &narrative)
|
||||
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
|
||||
}
|
||||
|
||||
err = dev.Navigation.SetNarrative(narrative)
|
||||
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
|
||||
}
|
||||
case "manDist":
|
||||
var manDist string
|
||||
err = navigator.StoreProperty(manDistProperty, &manDist)
|
||||
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
|
||||
}
|
||||
|
||||
err = dev.Navigation.SetManDist(manDist)
|
||||
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
|
||||
}
|
||||
case "progress":
|
||||
var progress int32
|
||||
err = navigator.StoreProperty(progressProperty, &progress)
|
||||
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
|
||||
}
|
||||
|
||||
err = dev.Navigation.SetProgress(uint8(progress))
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -149,7 +149,7 @@ func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
|
||||
}()
|
||||
|
||||
if exists {
|
||||
log.Info().Msg("Sending PureMaps data to InfiniTime")
|
||||
log.Info("Sending PureMaps data to InfiniTime").Send()
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/logger/log"
|
||||
_ "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
|
||||
}
|
||||
|
4
music.go
4
music.go
@ -21,10 +21,10 @@ package main
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/itd/mpris"
|
||||
"go.arsenm.dev/itd/translit"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
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.Info().Msg("Initialized InfiniTime music controls")
|
||||
log.Info("Initialized InfiniTime music controls").Send()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/godbus/dbus/v5"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/itd/internal/utils"
|
||||
"go.arsenm.dev/itd/translit"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/drpc/muxserver"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/infinitime/blefs"
|
||||
"go.arsenm.dev/itd/internal/rpc"
|
||||
"go.arsenm.dev/logger/log"
|
||||
"storj.io/drpc/drpcmux"
|
||||
)
|
||||
|
||||
@ -62,7 +62,7 @@ func startSocket(ctx context.Context, dev *infinitime.Device) error {
|
||||
|
||||
fs, err := dev.FS()
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Msg("Error getting BLE filesystem")
|
||||
log.Warn("Error getting BLE filesystem").Err(err).Send()
|
||||
}
|
||||
|
||||
mux := drpcmux.New()
|
||||
@ -80,7 +80,7 @@ func startSocket(ctx context.Context, dev *infinitime.Device) error {
|
||||
go muxserver.New(mux).Serve(ctx, ln)
|
||||
|
||||
// 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
|
||||
}
|
||||
@ -445,7 +445,7 @@ func (fs *FS) updateFS() {
|
||||
// Get new FS
|
||||
newFS, err := fs.dev.FS()
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Msg("Error updating BLE filesystem")
|
||||
log.Warn("Error updating BLE filesystem").Err(err).Send()
|
||||
} else {
|
||||
// Set FS pointer to new FS
|
||||
fs.fs = newFS
|
||||
|
16
weather.go
16
weather.go
@ -11,9 +11,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/infinitime/weather"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
// METResponse represents a response from
|
||||
@ -79,7 +79,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
||||
// Attempt to get weather
|
||||
data, err := getWeather(ctx, lat, lon)
|
||||
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
|
||||
time.Sleep(15 * time.Minute)
|
||||
continue
|
||||
@ -99,7 +99,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
||||
DewPoint: int16(round(currentData.DewPoint)),
|
||||
})
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error adding temperature event")
|
||||
log.Error("Error adding temperature event").Err(err).Send()
|
||||
}
|
||||
|
||||
// Add precipitation event
|
||||
@ -112,7 +112,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
||||
Amount: uint8(round(current.Data.NextHour.Details.PrecipitationAmount)),
|
||||
})
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error adding precipitation event")
|
||||
log.Error("Error adding precipitation event").Err(err).Send()
|
||||
}
|
||||
|
||||
// Add wind event
|
||||
@ -127,7 +127,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
||||
DirectionMax: uint8(round(currentData.WindDirection)),
|
||||
})
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error adding wind event")
|
||||
log.Error("Error adding wind event").Err(err).Send()
|
||||
}
|
||||
|
||||
// Add cloud event
|
||||
@ -139,7 +139,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
||||
Amount: uint8(round(currentData.CloudAreaFraction)),
|
||||
})
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error adding clouds event")
|
||||
log.Error("Error adding clouds event").Err(err).Send()
|
||||
}
|
||||
|
||||
// Add humidity event
|
||||
@ -151,7 +151,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
||||
Humidity: uint8(round(currentData.RelativeHumidity)),
|
||||
})
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error adding humidity event")
|
||||
log.Error("Error adding humidity event").Err(err).Send()
|
||||
}
|
||||
|
||||
// Add pressure event
|
||||
@ -163,7 +163,7 @@ func initWeather(ctx context.Context, dev *infinitime.Device) error {
|
||||
Pressure: int16(round(currentData.AirPressure)),
|
||||
})
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user