Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nomad logs command to stream task logs #1444

Merged
merged 16 commits into from
Jul 25, 2016
Prev Previous commit
Next Next commit
remove file events and last offset
  • Loading branch information
dadgar committed Jul 25, 2016
commit 8cb4f76a65710716948e86cbc43c2e8724621a93
21 changes: 0 additions & 21 deletions api/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,6 @@ type FrameReader struct {
frame *StreamFrame
frameOffset int

// To handle printing the file events
fileEventOffset int
fileEvent []byte

byteOffset int
}

Expand Down Expand Up @@ -417,23 +413,6 @@ func (f *FrameReader) Read(p []byte) (n int, err error) {
}
}

if f.frame.FileEvent != "" && len(f.fileEvent) == 0 {
f.fileEvent = []byte(fmt.Sprintf("\nnomad: %q\n", f.frame.FileEvent))
f.fileEventOffset = 0
}

// If there is a file event we inject it into the read stream
if l := len(f.fileEvent); l != 0 && l != f.fileEventOffset {
n = copy(p, f.fileEvent[f.fileEventOffset:])
f.fileEventOffset += n
return n, nil
}

if len(f.fileEvent) == f.fileEventOffset {
f.fileEvent = nil
f.fileEventOffset = 0
}

// Copy the data out of the frame and update our offset
n = copy(p, f.frame.Data[f.frameOffset:])
f.frameOffset += n
Expand Down
3 changes: 0 additions & 3 deletions command/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,6 @@ func (f *FSCommand) followFile(client *api.Client, alloc *api.Allocation,

// End the streaming
r.Close()

// Output the last offset
f.Ui.Output(fmt.Sprintf("\nLast outputted offset (bytes): %d", frameReader.Offset()))
}()

return r, nil
Expand Down
3 changes: 0 additions & 3 deletions command/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ func (l *LogsCommand) followFile(client *api.Client, alloc *api.Allocation,

// End the streaming
r.Close()

// Output the last offset
l.Ui.Output(fmt.Sprintf("\nLast outputted offset (bytes): %d", frameReader.Offset()))
}()

return r, nil
Expand Down