Skip to content

Commit 38f9a57

Browse files
committed
Fix data race
1 parent f8d0739 commit 38f9a57

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

gs/app.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ type AppEvent interface {
4545

4646
// App Ioc App
4747
type App struct {
48-
logger *Logger
4948
container *container
5049
exitChan chan struct{}
5150
}
@@ -88,14 +87,14 @@ func (app *App) run(resourceLocator ResourceLocator) error {
8887
return err
8988
}
9089

91-
app.logger = GetLogger("", utils.TypeName(app))
90+
var logger = GetLogger("", utils.TypeName(app))
9291

9392
app.onAppRun(app.container)
9493

9594
app.onAppStart(app.container)
9695

9796
app.container.clear()
98-
app.logger.Info("application started successfully")
97+
logger.Info("application started successfully")
9998

10099
// Responding to the Ctrl+C and kill commands in the console.
101100
go func() {
@@ -111,7 +110,7 @@ func (app *App) run(resourceLocator ResourceLocator) error {
111110

112111
app.container.Close()
113112

114-
app.logger.Info("application exited")
113+
logger.Info("application exited")
115114

116115
return nil
117116
}
@@ -186,7 +185,8 @@ func (app *App) Shutdown(msg ...string) {
186185
case <-app.exitChan:
187186
// app already closed
188187
default:
189-
app.logger.Info(fmt.Sprintf("program will exit %s", strings.Join(msg, ", ")))
188+
var logger = GetLogger("", utils.TypeName(app))
189+
logger.Info(fmt.Sprintf("program will exit %s", strings.Join(msg, ", ")))
190190
close(app.exitChan)
191191
}
192192
}

0 commit comments

Comments
 (0)