Logging api

Reviewers:  @bernerdschaefer, @peterbourgon 

First pass at the internals of the logging API.  This is two layers thick.  There is a RingBuffer for log messages, and on top of this is a data structure that implements storage for and operations for each container.  (The RingBuffer probably should have been a separate submit.)

The next piece to be worked on will be the HTTP logging interface.
Done.


On Tue, Jul 29, 2014 at 4:23 PM, Peter Bourgon <notifications@github.com>
wrote:

> In harpoon-agent/logs.go:
>
> > +}
> > +
> > +func (ls *LogSet) getContainerLog(containerID ContainerID) *containerLog {
> > +	x, ok := ls.logs[containerID]
> > +	if !ok {
> > +		x = newContainerLog(containerID, ls.bufferSize)
> > +	}
> > +	ls.logs[containerID] = x
> > +	return x
> > +}
> > +
> > +// Ring buffer that allows you to retrieve the last n records.  Retrieval calls are idempotent.
> > +type RingBuffer struct {
> > +	elements *ring.Ring
> > +	length int
> > +	mutex sync.Mutex
>
> You can embed the mutex, so you don't have to refer to it explicitly.
>
> type RingBuffer struct {
>     sync.Mutex
>     elements *ring.Ring
>     length   int}
>
> Then, later,
>
> func (b *RingBuffer) Insert(s string) {
>     b.Lock()
>     defer b.Unlock()
>     // ...}
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/soundcloud/harpoon/pull/13/files#r15525349>.
>