deepsource: fix confusing naming of struct fields

This commit is contained in:
nichtsen 2021-09-08 14:03:59 +08:00
parent 1a52d005b1
commit 16549e5019
2 changed files with 9 additions and 9 deletions

View File

@ -73,8 +73,8 @@ type fileLogWriter struct {
fileNameOnly, suffix string // like "project.log", project is fileNameOnly and .log is suffix
formatter LogFormatter
Formatter string `json:"formatter"`
logFormatter LogFormatter
Formatter string `json:"formatter"`
}
// newFileWriter creates a FileLogWriter returning as LoggerInterface.
@ -93,7 +93,7 @@ func newFileWriter() Logger {
MaxFiles: 999,
MaxSize: 1 << 28,
}
w.formatter = w
w.logFormatter = w
return w
}
@ -105,7 +105,7 @@ func (*fileLogWriter) Format(lm *LogMsg) string {
}
func (w *fileLogWriter) SetFormatter(f LogFormatter) {
w.formatter = f
w.logFormatter = f
}
// Init file logger with json config.
@ -138,7 +138,7 @@ func (w *fileLogWriter) Init(config string) error {
if !ok {
return fmt.Errorf("the formatter with name: %s not found", w.Formatter)
}
w.formatter = fmtr
w.logFormatter = fmtr
}
err = w.startLogger()
return err
@ -177,7 +177,7 @@ func (w *fileLogWriter) WriteMsg(lm *LogMsg) error {
_, d, h := formatTimeHeader(lm.When)
msg := w.formatter.Format(lm)
msg := w.logFormatter.Format(lm)
if w.Rotate {
w.RLock()
if w.needRotateHourly(h) {

View File

@ -324,7 +324,7 @@ func testFileRotate(t *testing.T, fn1, fn2 string, daily, hourly bool) {
DirPerm: "0770",
RotatePerm: "0440",
}
fw.formatter = fw
fw.logFormatter = fw
if daily {
fw.Init(fmt.Sprintf(`{"filename":"%v","maxdays":1}`, fn1))
@ -366,7 +366,7 @@ func testFileDailyRotate(t *testing.T, fn1, fn2 string) {
DirPerm: "0770",
RotatePerm: "0440",
}
fw.formatter = fw
fw.logFormatter = fw
fw.Init(fmt.Sprintf(`{"filename":"%v","maxdays":1}`, fn1))
fw.dailyOpenTime = time.Now().Add(-24 * time.Hour)
@ -402,7 +402,7 @@ func testFileHourlyRotate(t *testing.T, fn1, fn2 string) {
RotatePerm: "0440",
}
fw.formatter = fw
fw.logFormatter = fw
fw.Init(fmt.Sprintf(`{"filename":"%v","maxhours":1}`, fn1))
fw.hourlyOpenTime = time.Now().Add(-1 * time.Hour)
fw.hourlyOpenDate = fw.hourlyOpenTime.Hour()