Skip to content

Commit

Permalink
Remove NewStringFunc
Browse files Browse the repository at this point in the history
It's not needed when you can just do logg.StringFunc(...).
  • Loading branch information
bep committed Aug 24, 2022
1 parent b188ee0 commit ac765c2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func Example_lazy_evaluation() {

}),
)
ctx.Log(logg.NewStringFunc(
ctx.Log(logg.StringFunc(
// This func will never be invoked with the current logger's level.
func() string {
return "log message: " + strings.Repeat("x", 9999)
Expand Down
5 changes: 0 additions & 5 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ func (f StringFunc) String() string {
return f()
}

// NewStringFunc returns a StringFunc which implements Stringer.
func NewStringFunc(f func() string) StringFunc {
return StringFunc(f)
}

func (s String) String() string {
return string(s)
}
Expand Down
2 changes: 1 addition & 1 deletion logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func BenchmarkLogger_context_many_fields_duplicate_names_with_fields(b *testing.
func BenchmarkLogger_levels(b *testing.B) {
doWork := func(l logg.LevelLogger) {
for i := 0; i < 10; i++ {
l.Log(logg.NewStringFunc(
l.Log(logg.StringFunc(
func() string {
return fmt.Sprintf("loging value %s and %s.", "value1", strings.Repeat("value2", i+1))
},
Expand Down

0 comments on commit ac765c2

Please # to comment.