File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 8
8
"time"
9
9
10
10
"github.com/gookit/goutil/byteutil"
11
+ "github.com/gookit/goutil/fsutil"
11
12
"github.com/gookit/goutil/testutil/assert"
12
13
"github.com/gookit/goutil/timex"
13
14
"github.com/gookit/slog"
@@ -185,3 +186,23 @@ func TestIssues_121(t *testing.T) {
185
186
186
187
l .MustClose ()
187
188
}
189
+
190
+ // https://github.com/gookit/slog/issues/137
191
+ // 按日期滚动 如果当天时间节点的日志文件已存在 不会append 会直接替换 #137
192
+ func TestIssues_137 (t * testing.T ) {
193
+ logFile := "testdata/issue137_case.log"
194
+ fsutil .MustSave (logFile , "hello, this is a log file content\n " )
195
+
196
+ l := slog .NewWithHandlers (handler .MustFileHandler (logFile ))
197
+
198
+ // add logs
199
+ for i := 0 ; i < 5 ; i ++ {
200
+ l .Infof ("hi, this is a example information ... message text. log index=%d" , i )
201
+ }
202
+
203
+ l .MustClose ()
204
+ // read file content
205
+ content := fsutil .ReadString (logFile )
206
+ assert .StrContains (t , content , "this is a log file content" )
207
+ assert .StrContains (t , content , "log index=4" )
208
+ }
You can’t perform that action at this time.
0 commit comments