Skip to content

Commit

Permalink
Adds a .Env function on syslog messages:
Browse files Browse the repository at this point in the history
- This allows you to use docker container environment variables in the
  templates for things like SYSLOG_TAG
  • Loading branch information
dfuentes authored and Daniel Fuentes committed May 11, 2015
1 parent 3e49b29 commit 4f39700
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions adapters/syslog/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net"
"os"
"reflect"
"strings"
"text/template"
"time"

Expand Down Expand Up @@ -132,3 +133,13 @@ func (m *SyslogMessage) Timestamp() string {
func (m *SyslogMessage) ContainerName() string {
return m.Message.Container.Name[1:]
}

func (m *SyslogMessage) Env(key string) string {
envValues := m.Message.Container.Config.Env
for _, env := range envValues {
if strings.HasPrefix(env, key) {
return env[len(key)+1:]
}
}
return ""
}

0 comments on commit 4f39700

Please sign in to comment.