diff --git a/.mage/magefile.go b/.mage/magefile.go index a5a38fb9..00f4c622 100644 --- a/.mage/magefile.go +++ b/.mage/magefile.go @@ -12,7 +12,7 @@ import ( "go.einride.tech/mage-tools/targets/mgmarkdownfmt" // mage:import - "go.einride.tech/mage-tools/targets/mgcocogitto" + "go.einride.tech/mage-tools/targets/mgconvco" // mage:import "go.einride.tech/mage-tools/targets/mggo" @@ -38,7 +38,7 @@ func init() { func All() { mg.Deps( - mgcocogitto.CogCheck, + mg.F(mgconvco.ConvcoCheck, "origin/main..HEAD"), mggolangcilint.GolangciLint, mggoreview.Goreview, mgmarkdownfmt.FormatMarkdown, diff --git a/Makefile b/Makefile index 9a786bee..4540765f 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,12 @@ include .mage/tools.mk all: $(mage) @$(mage) all -.PHONY: cog-check -cog-check: $(mage) - @$(mage) cogCheck +.PHONY: convco-check +convco-check: $(mage) +ifndef rev + $(error missing argument rev="...") +endif + @$(mage) convcoCheck $(rev) .PHONY: format-markdown format-markdown: $(mage) diff --git a/mglog/logger.go b/mglog/logger.go index db2faf92..d6a8265f 100644 --- a/mglog/logger.go +++ b/mglog/logger.go @@ -4,15 +4,25 @@ import ( "fmt" "github.com/go-logr/logr" + "github.com/go-logr/logr/funcr" ) // Logger returns a standard logger. func Logger(name string) logr.Logger { - return logr.New(&sink{}).WithName(name) + return logr.New(&sink{ + name: name, + formatter: funcr.NewFormatter(funcr.Options{ + RenderBuiltinsHook: func(kvList []interface{}) []interface{} { + // Don't render builtins. + return nil + }, + }), + }) } type sink struct { - name string + formatter funcr.Formatter + name string } func (s *sink) Init(info logr.RuntimeInfo) { @@ -23,19 +33,13 @@ func (s *sink) Enabled(level int) bool { } func (s *sink) Info(level int, msg string, keysAndValues ...interface{}) { - if len(keysAndValues) > 0 { - fmt.Printf("[%s] %s (%v)\n", s.name, msg, keysAndValues) - } else { - fmt.Printf("[%s] %s\n", s.name, msg) - } + _, args := s.formatter.FormatInfo(level, msg, keysAndValues) + fmt.Printf("[%s] %s%s\n", s.name, msg, args) } func (s *sink) Error(err error, msg string, keysAndValues ...interface{}) { - if len(keysAndValues) > 0 { - fmt.Printf("[%s - ERROR] %s (%v)\n", s.name, msg, keysAndValues) - } else { - fmt.Printf("[%s - ERROR] %s\n", s.name, msg) - } + _, args := s.formatter.FormatError(err, msg, keysAndValues) + fmt.Printf("[%s | ERROR] %s%s\n", s.name, msg, args) } func (s *sink) WithValues(keysAndValues ...interface{}) logr.LogSink {