Skip to content

Commit c1c5888

Browse files
committed
Convert relative paths to absolute paths when tailing
This makes it possible to run `symfony server:log --file=var/dev.log` while the `var/dev.log` does not exist yet. When the file is created after the tailer has been started, inotify will emit an event where `e.Path()` is an absolute path. We need to compare that with the absolute path to be able to start the tailer the first time.
1 parent f239bc7 commit c1c5888

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

local/logs/tailer.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ func (tailer *Tailer) Watch(pidFile *pid.PidFile) error {
133133
for _, applog := range applogs {
134134
watcherChan := make(chan inotify.EventInfo, 1)
135135

136+
// Convert relative paths to absolute paths
137+
absAppLog, err := filepath.Abs(applog)
138+
if err != nil {
139+
return errors.Wrapf(err, "unable to get absolute path for %s", applog)
140+
}
141+
applog = absAppLog
142+
136143
dir := filepath.Dir(applog)
137144
if err := os.MkdirAll(dir, 0755); err != nil {
138145
return err

0 commit comments

Comments
 (0)