Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/log: replace gen.sh by a go template generator #57589

Merged
merged 1 commit into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' >>[email protected] || { rm -f [email protected]; exit 1; }
@mv -f [email protected] $@

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

pkg/util/log/severity/severity_generated.go: pkg/util/log/gen.sh pkg/util/log/logpb/log.proto
bash $< severity.go >[email protected] || { rm -f [email protected]; 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 [email protected] || { rm -f [email protected]; exit 1; }
mv -f [email protected] $@
gofmt -s -w $@

pkg/util/log/channel/channel_generated.go: pkg/util/log/gen.sh pkg/util/log/logpb/log.proto
bash $< channel.go >[email protected] || { rm -f [email protected]; 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 [email protected] || { rm -f [email protected]; exit 1; }
mv -f [email protected] $@
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 >[email protected] || { rm -f [email protected]; 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 [email protected] || { rm -f [email protected]; exit 1; }
mv -f [email protected] $@
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