mirror of https://github.com/v2ray/v2ray-core
fix default logger
parent
42e9af63aa
commit
84f8192b61
|
@ -24,8 +24,9 @@ type Instance struct {
|
||||||
func New(ctx context.Context, config *Config) (*Instance, error) {
|
func New(ctx context.Context, config *Config) (*Instance, error) {
|
||||||
g := &Instance{
|
g := &Instance{
|
||||||
config: config,
|
config: config,
|
||||||
active: true,
|
active: false,
|
||||||
}
|
}
|
||||||
|
log.RegisterHandler(g)
|
||||||
|
|
||||||
v := core.FromContext(ctx)
|
v := core.FromContext(ctx)
|
||||||
if v != nil {
|
if v != nil {
|
||||||
|
@ -65,14 +66,12 @@ func (g *Instance) initErrorLogger() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type implements common.HasType.
|
||||||
func (*Instance) Type() interface{} {
|
func (*Instance) Type() interface{} {
|
||||||
return (*Instance)(nil)
|
return (*Instance)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start implements app.Application.Start().
|
func (g *Instance) startInternal() error {
|
||||||
func (g *Instance) Start() error {
|
|
||||||
newError("Logger starting").AtDebug().WriteToLog()
|
|
||||||
|
|
||||||
g.Lock()
|
g.Lock()
|
||||||
defer g.Unlock()
|
defer g.Unlock()
|
||||||
|
|
||||||
|
@ -88,7 +87,17 @@ func (g *Instance) Start() error {
|
||||||
if err := g.initErrorLogger(); err != nil {
|
if err := g.initErrorLogger(); err != nil {
|
||||||
return newError("failed to initialize error logger").Base(err).AtWarning()
|
return newError("failed to initialize error logger").Base(err).AtWarning()
|
||||||
}
|
}
|
||||||
log.RegisterHandler(g)
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start implements app.Application.Start().
|
||||||
|
func (g *Instance) Start() error {
|
||||||
|
if err := g.startInternal(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
newError("Logger started").AtDebug().WriteToLog()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -130,7 +139,10 @@ func (g *Instance) Close() error {
|
||||||
g.active = false
|
g.active = false
|
||||||
|
|
||||||
common.Close(g.accessLogger)
|
common.Close(g.accessLogger)
|
||||||
|
g.accessLogger = nil
|
||||||
|
|
||||||
common.Close(g.errorLogger)
|
common.Close(g.errorLogger)
|
||||||
|
g.errorLogger = nil
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue