diff --git a/go.sum b/go.sum index 852457f..bfdf376 100644 --- a/go.sum +++ b/go.sum @@ -23,6 +23,8 @@ github.com/shimmeringbee/persistence v0.0.0-20240615120347-680c4a887f1b h1:TD++F github.com/shimmeringbee/persistence v0.0.0-20240615120347-680c4a887f1b/go.mod h1:Ob1eKGYM7+9P3LkB9vB9nr15d3trtS4D9KOnGoxOkp8= github.com/shimmeringbee/persistence v0.0.0-20240615120714-a567d1ac9349 h1:IQ2JhhUVsATqnGav6KOJRqLFDZ80wCYYG3yawTVlylI= github.com/shimmeringbee/persistence v0.0.0-20240615120714-a567d1ac9349/go.mod h1:Ob1eKGYM7+9P3LkB9vB9nr15d3trtS4D9KOnGoxOkp8= +github.com/shimmeringbee/persistence v0.0.0-20240615141034-6414db99d48e h1:hxB9Zczd27kKbOMoiK56CaHgFKDyIYQLVCD1WV+LlgA= +github.com/shimmeringbee/persistence v0.0.0-20240615141034-6414db99d48e/go.mod h1:Ob1eKGYM7+9P3LkB9vB9nr15d3trtS4D9KOnGoxOkp8= github.com/shimmeringbee/retry v0.0.0-20221006193055-2ce01bf139c2 h1:HxpPz7w7SxVf1GmcM5oTK1JK64TGpK1UflweYRSOwC4= github.com/shimmeringbee/retry v0.0.0-20221006193055-2ce01bf139c2/go.mod h1:KYvVq5b7/BSSlWng+AKB5jwNGpc0D7eg8ySWrdPAlms= github.com/shimmeringbee/zcl v0.0.0-20240614085730-dc48ec71c312 h1:OoFxM9W299ESRnPSR3NoK4+AmWz5PzcJ4gJFZ62nkZ0= diff --git a/provider_load.go b/provider_load.go index d7449d2..55b4eea 100644 --- a/provider_load.go +++ b/provider_load.go @@ -35,28 +35,32 @@ func (g *gateway) providerLoadDevice(pctx context.Context, n *node, i IEEEAddres capSection := g.sectionForDevice(i).Section("capability") for _, cName := range capSection.SectionKeys() { + cctx, cend := g.logger.Segment(ctx, "Loading capability data.", logwrap.Datum("capability", cName)) + cSection := capSection.Section(cName) if capImpl, ok := cSection.String("implementation"); ok { if capI := factory.Create(capImpl, g.zdaInterface); capI == nil { - g.logger.LogError(ctx, "Could not find capability implementation.", logwrap.Datum("implementation", capImpl)) + g.logger.LogError(cctx, "Could not find capability implementation.", logwrap.Datum("implementation", capImpl)) continue } else { - g.logger.LogInfo(ctx, "Constructed capability implementation.", logwrap.Datum("implementation", capImpl)) + g.logger.LogInfo(cctx, "Constructed capability implementation.", logwrap.Datum("implementation", capImpl)) capI.Init(d, cSection.Section("data")) - attached, err := capI.Load(ctx) + attached, err := capI.Load(cctx) if err != nil { - g.logger.LogError(ctx, "Error while loading from persistence.", logwrap.Err(err), logwrap.Datum("implementation", capImpl)) + g.logger.LogError(cctx, "Error while loading from persistence.", logwrap.Err(err), logwrap.Datum("implementation", capImpl)) } if attached { g.attachCapabilityToDevice(d, capI) - g.logger.LogInfo(ctx, "Attached capability from persistence.", logwrap.Datum("implementation", capImpl)) + g.logger.LogInfo(cctx, "Attached capability from persistence.", logwrap.Datum("implementation", capImpl)) } else { - g.logger.LogWarn(ctx, "Rejected capability attach from persistence.", logwrap.Datum("implementation", capImpl)) + g.logger.LogWarn(cctx, "Rejected capability attach from persistence.", logwrap.Datum("implementation", capImpl)) } } } + + cend() } }