Refactor log factory constructor

This commit is contained in:
世界
2023-04-03 18:24:20 +08:00
parent 0be3cdc8fb
commit 28aa4c4d1f
10 changed files with 164 additions and 74 deletions

View File

@@ -26,7 +26,10 @@ func CheckConfig(configContent string) error {
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
instance, err := box.New(ctx, options, nil)
instance, err := box.New(box.Options{
Context: ctx,
Options: options,
})
if err == nil {
instance.Close()
}

View File

@@ -30,7 +30,11 @@ func NewService(configContent string, platformInterface PlatformInterface) (*Box
return nil, err
}
ctx, cancel := context.WithCancel(context.Background())
instance, err := box.New(ctx, options, &platformInterfaceWrapper{platformInterface, platformInterface.UseProcFS()})
instance, err := box.New(box.Options{
Context: ctx,
Options: options,
PlatformInterface: &platformInterfaceWrapper{platformInterface, platformInterface.UseProcFS()},
})
if err != nil {
cancel()
return nil, E.Cause(err, "create service")