优化一些option初始值
This commit is contained in:
+7
-1
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user