优化一些option初始值

This commit is contained in:
Yun
2024-04-15 23:40:55 +08:00
parent c7acaa5af6
commit b58849b5b2
3 changed files with 15 additions and 6 deletions
+7 -1
View File
@@ -32,7 +32,7 @@ type filePath struct {
fileName string
}
func NewLogger(opts ...Option) *Logger {
func NewLogger(ctx context.Context, opts ...Option) *Logger {
opt := defaultOptions()
for _, apply := range opts {
apply(&opt)
@@ -61,6 +61,12 @@ func NewLogger(opts ...Option) *Logger {
// 日志删除
go l.delete()
// 强制刷盘
go func() {
<-ctx.Done()
l.MustSync()
}()
return l
}