Skip to content

Commit

Permalink
feat: rename CustomCallerPrettyfier option to CustomCallerFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
antonfisher committed May 2, 2020
1 parent fea031b commit 28a283d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type Formatter struct {
// CallerFirst - print caller info first
CallerFirst bool

// CustomCallerPrettyfier - set custom formatter for caller info
CustomCallerPrettyfier func(*runtime.Frame) string
// CustomCallerFormatter - set custom formatter for caller info
CustomCallerFormatter func(*runtime.Frame) string
}
```

Expand Down
8 changes: 4 additions & 4 deletions formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type Formatter struct {
// CallerFirst - print caller info first
CallerFirst bool

// CustomCallerPrettyfier - set custom formatter for caller info
CustomCallerPrettyfier func(*runtime.Frame) string
// CustomCallerFormatter - set custom formatter for caller info
CustomCallerFormatter func(*runtime.Frame) string
}

// Format an log entry
Expand Down Expand Up @@ -108,8 +108,8 @@ func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error) {

func (f *Formatter) writeCaller(b *bytes.Buffer, entry *logrus.Entry) {
if entry.HasCaller() {
if f.CustomCallerPrettyfier != nil {
fmt.Fprintf(b, f.CustomCallerPrettyfier(entry.Caller))
if f.CustomCallerFormatter != nil {
fmt.Fprintf(b, f.CustomCallerFormatter(entry.Caller))
} else {
fmt.Fprintf(
b,
Expand Down
4 changes: 2 additions & 2 deletions tests/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func TestFormatter_Format_with_report_caller_and_CallerFirst_true(t *testing.T)
}
}

func TestFormatter_Format_with_report_caller_and_CustomCallerPrettyfier(t *testing.T) {
func TestFormatter_Format_with_report_caller_and_CustomCallerFormatter(t *testing.T) {
output := bytes.NewBuffer([]byte{})

l := logrus.New()
Expand All @@ -247,7 +247,7 @@ func TestFormatter_Format_with_report_caller_and_CustomCallerPrettyfier(t *testi
NoColors: true,
TimestampFormat: "-",
CallerFirst: true,
CustomCallerPrettyfier: func(f *runtime.Frame) string {
CustomCallerFormatter: func(f *runtime.Frame) string {
s := strings.Split(f.Function, ".")
funcName := s[len(s)-1]
return fmt.Sprintf(" [%s:%d][%s()]", path.Base(f.File), f.Line, funcName)
Expand Down

0 comments on commit 28a283d

Please sign in to comment.