mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 16:59:22 +02:00
log context (#2107)
This commit is contained in:
parent
e7995954ff
commit
e0c09a0998
87 changed files with 714 additions and 524 deletions
|
@ -5,7 +5,8 @@ import (
|
|||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/pomerium/pomerium/internal/log"
|
||||
|
||||
"golang.org/x/net/publicsuffix"
|
||||
)
|
||||
|
||||
|
@ -51,6 +52,6 @@ type loggingRoundTripper struct {
|
|||
|
||||
func (rt *loggingRoundTripper) RoundTrip(req *http.Request) (res *http.Response, err error) {
|
||||
res, err = rt.RoundTripper.RoundTrip(req)
|
||||
log.Debug().Str("method", req.Method).Str("url", req.URL.String()).Msg("http request")
|
||||
log.Debug(req.Context()).Str("method", req.Method).Str("url", req.URL.String()).Msg("http request")
|
||||
return res, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/pomerium/pomerium/internal/log"
|
||||
)
|
||||
|
||||
type cmdOption func(*exec.Cmd)
|
||||
|
@ -53,7 +53,7 @@ func run(ctx context.Context, name string, options ...cmdOption) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to create stderr pipe for %s: %w", name, err)
|
||||
}
|
||||
go cmdLogger(stderr)
|
||||
go cmdLogger(ctx, stderr)
|
||||
defer stderr.Close()
|
||||
}
|
||||
if cmd.Stdout == nil {
|
||||
|
@ -61,17 +61,17 @@ func run(ctx context.Context, name string, options ...cmdOption) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to create stdout pipe for %s: %w", name, err)
|
||||
}
|
||||
go cmdLogger(stdout)
|
||||
go cmdLogger(ctx, stdout)
|
||||
defer stdout.Close()
|
||||
}
|
||||
|
||||
log.Debug().Strs("args", cmd.Args).Msgf("running %s", name)
|
||||
log.Debug(ctx).Strs("args", cmd.Args).Msgf("running %s", name)
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func cmdLogger(rdr io.Reader) {
|
||||
func cmdLogger(ctx context.Context, rdr io.Reader) {
|
||||
s := bufio.NewScanner(rdr)
|
||||
for s.Scan() {
|
||||
log.Debug().Msg(s.Text())
|
||||
log.Debug(ctx).Msg(s.Text())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-jsonnet"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/pomerium/pomerium/integration/internal/netutil"
|
||||
"github.com/pomerium/pomerium/internal/log"
|
||||
)
|
||||
|
||||
var requiredDeployments = []string{
|
||||
|
@ -180,7 +180,7 @@ func applyManifests(ctx context.Context, jsonsrc string) error {
|
|||
return fmt.Errorf("error applying manifests: %w", err)
|
||||
}
|
||||
|
||||
log.Info().Msg("waiting for deployments to come up")
|
||||
log.Info(ctx).Msg("waiting for deployments to come up")
|
||||
ctx, clearTimeout := context.WithTimeout(ctx, 15*time.Minute)
|
||||
defer clearTimeout()
|
||||
ticker := time.NewTicker(time.Second * 5)
|
||||
|
@ -218,7 +218,7 @@ func applyManifests(ctx context.Context, jsonsrc string) error {
|
|||
for _, dep := range requiredDeployments {
|
||||
if byName[dep] < 1 {
|
||||
done = false
|
||||
log.Warn().Str("deployment", dep).Msg("deployment is not ready yet")
|
||||
log.Warn(ctx).Str("deployment", dep).Msg("deployment is not ready yet")
|
||||
}
|
||||
}
|
||||
if done {
|
||||
|
@ -233,7 +233,7 @@ func applyManifests(ctx context.Context, jsonsrc string) error {
|
|||
<-ticker.C
|
||||
}
|
||||
time.Sleep(time.Minute)
|
||||
log.Info().Msg("all deployments are ready")
|
||||
log.Info(ctx).Msg("all deployments are ready")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue