Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ Routes are stored on disk, so by default routes are ephemeral. You can mount a v

See [routesapi module](http://github.com/gliderlabs/logspout/blob/master/routesapi) for all options.

#### Suppressing backlog tail
You can tell logspout to only display log entries since container "start" or "restart" event by setting a `BACKLOG=false` environment variable (equivalent to `docker logs --tail=0`):

$ docker run -d --name="logspout" \
-e 'BACKLOG=false' \
--volume=/var/run/docker.sock:/var/run/docker.sock \
gliderlabs/logspout

The default behaviour is to output all logs since creation of the container (equivalent to `docker logs --tail=all` or simply `docker logs`).

> NOTE: Use of this option **may** cause the first few lines of log output to be missed following a container being started, if the container starts outputting logs before logspout has a chance to see them. If consistent capture of *every* line of logs is critical to your application, you might want to test thorougly and/or avoid this option (at the expense of getting the entire backlog for every restarting container). This does not affect containers that are removed and recreated.

## Modules

The standard distribution of logspout comes with all modules defined in this repository. You can remove or add new modules with custom builds of logspout. Just edit the `modules.go` file and do a `docker build`.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.2-dev
v3.3-dev
3 changes: 3 additions & 0 deletions logspout.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func main() {
if getopt("DEBUG", "") != "" {
fmt.Printf("debug:%s ", getopt("DEBUG", ""))
}
if getopt("BACKLOG", "") != "" {
fmt.Printf("backlog:%s ", getopt("BACKLOG", ""))
}
fmt.Printf("persist:%s\n", getopt("ROUTESPATH", "/mnt/routes"))

var jobs []string
Expand Down
9 changes: 8 additions & 1 deletion router/pump.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ func debug(v ...interface{}) {
}
}

func backlog() bool {
if os.Getenv("BACKLOG") == "false" {
return false
}
return true
}

func assert(err error, context string) {
if err != nil {
log.Fatal(context+": ", err)
Expand Down Expand Up @@ -131,7 +138,7 @@ func (p *LogsPump) Run() error {
debug("pump.Run() event:", normalID(event.ID), event.Status)
switch event.Status {
case "start", "restart":
go p.pumpLogs(event, true)
go p.pumpLogs(event, backlog())
case "rename":
go p.rename(event)
case "die":
Expand Down