mirror of
https://github.com/juanfont/headscale.git
synced 2026-04-24 09:38:45 +02:00
hscontrol/poll: use sub-logger pattern for mapSession
Replace the helper functions (logf, infof, tracef, errf) with a zerolog sub-logger initialized in newMapSession(). The sub-logger is pre-populated with session context (component, node, omitPeers, stream) eliminating repeated field calls throughout the code. Changes: - Add log field to mapSession struct - Initialize sub-logger with EmbedObject(node) and request context - Remove logf/infof/tracef/errf helper functions - Update all callers to use m.log.Level().Caller()... pattern - Update noise.go to use sess.log instead of sess.tracef This reduces code by ~20 lines and eliminates ~15 repeated field calls per log statement.
This commit is contained in:
@@ -218,7 +218,7 @@ func (ns *noiseServer) NoisePollNetMapHandler(
|
||||
ns.nodeKey = nv.NodeKey()
|
||||
|
||||
sess := ns.headscale.newMapSession(req.Context(), mapRequest, writer, nv.AsStruct())
|
||||
sess.tracef("a node sending a MapRequest with Noise protocol")
|
||||
sess.log.Trace().Caller().Msg("a node sending a MapRequest with Noise protocol")
|
||||
if !sess.isStreaming() {
|
||||
sess.serve()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user