Skip to content

Commit

Permalink
fixi: log with context in new tailscale proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidapaulopt committed Jan 3, 2025
1 parent 481b74c commit b0b1e11
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/proxyproviders/tailscale/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func (c *Client) NewProxy(config *proxyconfig.Config) (proxyproviders.ProxyInter
Str("hostname", config.Hostname).
Msg("Setting up tailscale server")

log := c.log.With().Str("Hostname", config.Hostname).Logger()

// If the auth key is not set, use the provider auth key
authKey := config.Tailscale.AuthKey
if authKey == "" {
Expand All @@ -59,10 +61,10 @@ func (c *Client) NewProxy(config *proxyconfig.Config) (proxyproviders.ProxyInter
Ephemeral: config.Tailscale.Ephemeral,
RunWebClient: config.Tailscale.RunWebClient,
UserLogf: func(format string, args ...any) {
c.log.Info().Msgf(format, args...)
log.Info().Msgf(format, args...)
},
Logf: func(format string, args ...any) {
c.log.Trace().Msgf(format, args...)
log.Trace().Msgf(format, args...)
},

ControlURL: c.getControlURL(config),
Expand All @@ -71,12 +73,12 @@ func (c *Client) NewProxy(config *proxyconfig.Config) (proxyproviders.ProxyInter
// if verbose is set, use the info log level
if config.Tailscale.Verbose {
tserver.Logf = func(format string, args ...any) {
c.log.Info().Msgf(format, args...)
log.Info().Msgf(format, args...)
}
}

return &Proxy{
log: c.log.With().Str("Hostname", config.Hostname).Logger(),
log: log,
config: config,
tsServer: tserver,
}, nil
Expand Down

0 comments on commit b0b1e11

Please sign in to comment.