Skip to content

Commit b29665f

Browse files
committed
-
1 parent 4f4683b commit b29665f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

local/runner.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"time"
3333

3434
"github.com/pkg/errors"
35+
"github.com/rs/zerolog"
3536
"github.com/symfony-cli/console"
3637
"github.com/symfony-cli/symfony-cli/inotify"
3738
"github.com/symfony-cli/symfony-cli/local/pid"
@@ -80,7 +81,12 @@ func NewRunner(pidFile *pid.PidFile, mode runnerMode) (*Runner, error) {
8081
}
8182

8283
func (r *Runner) Run() error {
83-
logger := terminal.Logger.With().Str("cmd", r.pidFile.String()).Logger()
84+
lw, err := r.pidFile.LogWriter()
85+
if err != nil {
86+
return err
87+
}
88+
logger := zerolog.New(lw).With().Str("source", "runner").Str("cmd", r.pidFile.String()).Timestamp().Logger()
89+
8490
if r.mode == RunnerModeLoopDetached {
8591
if !reexec.IsChild() {
8692
varDir := filepath.Join(util.GetHomeDir(), "var")
@@ -179,7 +185,6 @@ func (r *Runner) Run() error {
179185
if r.mode == RunnerModeLoopDetached {
180186
reexec.NotifyForeground("started")
181187
}
182-
183188
logger.Debug().Msg("Waiting for channels (first boot)")
184189
select {
185190
case err := <-cmdExitChan:

reexec/reexec.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func ExecBinaryWithEnv(binary string, envs []string) bool {
8585
}
8686

8787
func Background(homeDir string) error {
88+
terminal.Logger.Debug().Str("source", "reexec").Msg("let's go to the background!")
8889
if util.IsGoRun() {
8990
return errors.New("Not applicable in a Go run context")
9091
}
@@ -116,7 +117,6 @@ func Background(homeDir string) error {
116117
os.Setenv("REEXEC_WATCH_PID", shellPID)
117118
}
118119

119-
terminal.Logger.Debug().Msg("Let's go to the background!")
120120
p, err := Respawn()
121121
if err != nil {
122122
return errors.Wrap(err, "Could not respawn")
@@ -157,14 +157,13 @@ func Background(homeDir string) error {
157157
// end-up receiving a status in statusCh so no particular
158158
// processing to do here.
159159
case event := <-watcherChan:
160-
terminal.Logger.Info().Msg("FS event received: " + event.Event().String())
160+
terminal.Logger.Debug().Str("source", "reexec").Msg("FS event received: " + event.Event().String())
161161
if event.Event() == notify.Remove {
162162
return nil
163163
}
164164

165165
if event.Event() == notify.Write {
166166
ticker.Stop()
167-
break
168167
}
169168
case status := <-statusCh:
170169
return console.Exit("", status)
@@ -176,6 +175,7 @@ func Background(homeDir string) error {
176175
}
177176

178177
func NotifyForeground(status string) error {
178+
terminal.Logger.Debug().Str("source", "reexec").Msg("notify foreground")
179179
if !IsChild() {
180180
return nil
181181
}
@@ -195,6 +195,7 @@ func NotifyForeground(status string) error {
195195
}
196196

197197
func WatchParent(stopCh chan bool) error {
198+
terminal.Logger.Debug().Str("source", "reexec").Msg("watch parent")
198199
spid := os.Getenv("REEXEC_WATCH_PID")
199200
if spid == "" {
200201
return nil
@@ -223,6 +224,7 @@ func WatchParent(stopCh chan bool) error {
223224
}
224225

225226
func Restart(postRespawn func()) error {
227+
terminal.Logger.Debug().Str("source", "reexec").Msg("restart")
226228
if err := os.Setenv("REEXEC_PPID", fmt.Sprint(os.Getpid())); nil != err {
227229
return errors.WithStack(err)
228230
}
@@ -280,6 +282,7 @@ func Restart(postRespawn func()) error {
280282
}
281283

282284
func Respawn() (*os.Process, error) {
285+
terminal.Logger.Debug().Str("source", "reexec").Msg("respawn")
283286
argv0, err := console.CurrentBinaryPath()
284287
if err != nil {
285288
return nil, err

0 commit comments

Comments
 (0)