Merge lp:~thumper/juju-core/tailer-tweaks into lp:~go-bot/juju-core/trunk
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2563 |
Proposed branch: | lp:~thumper/juju-core/tailer-tweaks |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
150 lines (+45/-12) 3 files modified
container/lxc/clonetemplate.go (+1/-1) utils/tailer/tailer.go (+25/-9) utils/tailer/tailer_test.go (+19/-2) |
To merge this branch: | bzr merge lp:~thumper/juju-core/tailer-tweaks |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+214150@code.launchpad.net |
Commit message
Extend the tailer utility.
When looking at the pyjuju debug-log, there was a replay
function that allowed getting the log from the start.
There was no way to tell the tailer to start from the
beginning of the file.
I changed the meaning of NewTailer to be one that doesn't
do any seeking. The NewTailerBacktrack does seek to the end,
and then goes back a certain number of lines.
There was a bug in the backtrack tailer when zero lines
were passed in. This is fixed and a test added.
The number of lines to look back is now a uint, as negative
values make no sense at all.
Description of the change
Extend the tailer utility.
When looking at the pyjuju debug-log, there was a replay
function that allowed getting the log from the start.
There was no way to tell the tailer to start from the
beginning of the file.
I changed the meaning of NewTailer to be one that doesn't
do any seeking. The NewTailerBacktrack does seek to the end,
and then goes back a certain number of lines.
There was a bug in the backtrack tailer when zero lines
were passed in. This is fixed and a test added.
In order to provide a synchronization mechanism for other
tests, the Tailer has a public function param that is called
after the backtracking, and prior to starting tailing.
The number of lines to look back is now a unit, as negative
values make no sense at all.
Reviewers: mp+214150_ code.launchpad. net,
Message:
Please take a look.
Description:
Extend the tailer utility.
When looking at the pyjuju debug-log, there was a replay
function that allowed getting the log from the start.
There was no way to tell the tailer to start from the
beginning of the file.
I changed the meaning of NewTailer to be one that doesn't
do any seeking. The NewTailerBacktrack does seek to the end,
and then goes back a certain number of lines.
There was a bug in the backtrack tailer when zero lines
were passed in. This is fixed and a test added.
In order to provide a synchronization mechanism for other
tests, the Tailer has a public function param that is called
after the backtracking, and prior to starting tailing.
The number of lines to look back is now a unit, as negative
values make no sense at all.
https:/ /code.launchpad .net/~thumper/ juju-core/ tailer- tweaks/ +merge/ 214150
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/84290045/
Affected files (+53, -12 lines): lxc/clonetempla te.go tailer. go tailer_ test.go
A [revision details]
M container/
M utils/tailer/
M utils/tailer/
Index: [revision details] 20140404003547- v7dzlndz9bq9h4q d
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: container/ lxc/clonetempla te.go lxc/clonetempla te.go' lxc/clonetempla te.go 2014-03-12 04:32:02 +0000 lxc/clonetempla te.go 2014-04-04 03:33:01 +0000
=== modified file 'container/
--- container/
+++ container/
@@ -179,7 +179,7 @@
}
tailWriter := &logTail{tick: time.Now()} NewTailer( console, tailWriter, 0, nil) NewTailer( console, tailWriter, nil) Stop()
- consoleTailer := tailer.
+ consoleTailer := tailer.
defer consoleTailer.
// We should wait maybe 1 minute between output?
Index: utils/tailer/ tailer. go tailer/ tailer. go' tailer. go 2013-12-13 11:19:56 +0000 tailer. go 2014-04-04 03:20:53 +0000
=== modified file 'utils/
--- utils/tailer/
+++ utils/tailer/
@@ -35,25 +35,37 @@
reader *bufio.Reader
writeCloser io.WriteCloser
writer *bufio.Writer
- lines int
+ lines uint
filter TailerFilterFunc
bufferSize int
polltime time.Duration
+ lookBack bool
+ // StartedListening is purely a hook point for tests. It is a function
+ // that is called after the initial seek prior to reading.
+ StartedTailing func()
}
-// NewTailer starts a Tailer which reads strings from the passed readSeeker io.ReadSeeker, writer io.Writer, lines int, readSeeker, writer, lines, filter, bufferSize, polltime) ack(readSeeker io.ReadSeeker, writer io.Writer, lines ...
+// NewTailerBacktrack starts a Tailer which reads strings from the passed
// ReadSeeker line by line. If a filter function is specified the read
// lines are filtered. The matching lines are written to the passed
// Writer. The reading begins the specified number of matching lines
// from the end.
-func NewTailer(
filter TailerFilterFunc) *Tailer {
- return newTailer(
+func NewTailerBacktr