Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
57589: util/log: replace gen.sh by a go template generator r=otan a=knz

This prevents build problems due to folk not using a `bash` that's
modern enough.

Release note: None

Co-authored-by: Raphael 'kena' Poss <[email protected]>
  • Loading branch information
craig[bot] and knz committed Dec 7, 2020
2 parents 1ed669d + 0d98f9f commit 98e724e
Show file tree
Hide file tree
Showing 8 changed files with 497 additions and 470 deletions.
19 changes: 8 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1544,24 +1544,21 @@ docs/generated/redact_safe.md:
sed -E -e 's/^([^:]*):[0-9]+:.*redact\.RegisterSafeType\((.*)\).*/\1 | \`\2\`/g' >>$@.tmp || { rm -f $@.tmp; exit 1; }
@mv -f $@.tmp $@

docs/generated/logging.md: pkg/util/log/gen.sh pkg/util/log/logpb/log.proto
bash $< logging.md >$@.tmp || { rm -f $@.tmp; exit 1; }
docs/generated/logging.md: pkg/util/log/gen.go pkg/util/log/logpb/log.proto
$(GO) run $(GOFLAGS) $(GOMODVENDORFLAGS) $^ logging.md $@.tmp || { rm -f $@.tmp; exit 1; }
mv -f $@.tmp $@

pkg/util/log/severity/severity_generated.go: pkg/util/log/gen.sh pkg/util/log/logpb/log.proto
bash $< severity.go >$@.tmp || { rm -f $@.tmp; exit 1; }
pkg/util/log/severity/severity_generated.go: pkg/util/log/gen.go pkg/util/log/logpb/log.proto
$(GO) run $(GOFLAGS) $(GOMODVENDORFLAGS) $^ severity.go $@.tmp || { rm -f $@.tmp; exit 1; }
mv -f $@.tmp $@
gofmt -s -w $@

pkg/util/log/channel/channel_generated.go: pkg/util/log/gen.sh pkg/util/log/logpb/log.proto
bash $< channel.go >$@.tmp || { rm -f $@.tmp; exit 1; }
pkg/util/log/channel/channel_generated.go: pkg/util/log/gen.go pkg/util/log/logpb/log.proto
$(GO) run $(GOFLAGS) $(GOMODVENDORFLAGS) $^ channel.go $@.tmp || { rm -f $@.tmp; exit 1; }
mv -f $@.tmp $@
gofmt -s -w $@

pkg/util/log/log_channels_generated.go: pkg/util/log/gen.sh pkg/util/log/logpb/log.proto
bash $< log_channels.go >$@.tmp || { rm -f $@.tmp; exit 1; }
pkg/util/log/log_channels_generated.go: pkg/util/log/gen.go pkg/util/log/logpb/log.proto
$(GO) run $(GOFLAGS) $(GOMODVENDORFLAGS) $^ log_channels.go $@.tmp || { rm -f $@.tmp; exit 1; }
mv -f $@.tmp $@
gofmt -s -w $@

settings-doc-gen := $(if $(filter buildshort,$(MAKECMDGOALS)),$(COCKROACHSHORT),$(COCKROACH))

Expand Down
3 changes: 2 additions & 1 deletion docs/generated/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The FATAL severity is used for situations that require an immedate, hard
server shutdown. A report is also sent to telemetry if telemetry
is enabled.


# Logging channels

## DEV
Expand All @@ -33,7 +34,7 @@ CockroachDB, when the caller does not indicate a channel.

This channel is special in that there are no constraints as to
what may or may not be logged on it. Conversely, users in
production deployments are invited to not collect The DEV channel logs in
production deployments are invited to not collect DEV logs in
centralized logging facilities, because they likely contain
sensitive operational data.

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/log/channel/channel_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/util/log/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"github.com/cockroachdb/errors"
)

//go:generate ./gen.sh ../../../docs/generated/logging.md logging.md
//go:generate ./gen.sh severity/severity_generated.go severity.go
//go:generate ./gen.sh channel/channel_generated channel.go
//go:generate ./gen.sh log_channels_generated.go log_channels.go
//go:generate go run ./gen.go logpb/log.proto logging.md ../../../docs/generated/logging.md
//go:generate go run ./gen.go logpb/log.proto severity.go severity/severity_generated.go
//go:generate go run ./gen.go logpb/log.proto channel.go channel/channel_generated.go
//go:generate go run ./gen.go logpb/log.proto log_channels.go log_channels_generated.go

// Channel aliases a type.
type Channel = logpb.Channel
Expand Down
Loading

0 comments on commit 98e724e

Please sign in to comment.