Skip to content

Commit

Permalink
fix:修复日志打印行数不对的问题 (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun authored Jun 22, 2024
1 parent a4b578d commit 4bce62a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ polaris/
.vscode/

style_tool/
goimports-reviser
goimports-reviser
*.log
5 changes: 3 additions & 2 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package grpcpolaris

import (
"fmt"
"log"
"sync/atomic"

Expand Down Expand Up @@ -70,7 +71,7 @@ func newDefaultLogger() *defaultLogger {

levelRef.Store(LogInfo)
return &defaultLogger{
writer: log.New(lumberJackLogger, "", log.Llongfile|log.Ldate|log.Ltime),
writer: log.New(lumberJackLogger, "", log.Lshortfile|log.Ldate|log.Ltime),
levelRef: levelRef,
}
}
Expand Down Expand Up @@ -101,5 +102,5 @@ func (l *defaultLogger) printf(expectLevel LogLevel, format string, args ...inte
if curLevel > expectLevel {
return
}
l.writer.Printf(format, args...)
_ = l.writer.Output(3, fmt.Sprintf(format, args...))
}

0 comments on commit 4bce62a

Please sign in to comment.