Since 1.9, driver specific log tag options
`syslog-tag`
`gelf-tag`
`fluentd-tag`
have been deprecated in favor of the generic tag
option which is standard across different logging
drivers.
This fix removed the deprecated driver specific
log tag options of `syslog-tag`, `gelf-tag`,
`fluentd-tag` for 1.12 and updated the docs.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
... | ... |
@@ -57,8 +57,8 @@ func init() { |
57 | 57 |
} |
58 | 58 |
|
59 | 59 |
// New creates a fluentd logger using the configuration passed in on |
60 |
-// the context. Supported context configuration variables are |
|
61 |
-// fluentd-address & fluentd-tag. |
|
60 |
+// the context. The supported context configuration variable is |
|
61 |
+// fluentd-address. |
|
62 | 62 |
func New(ctx logger.Context) (logger.Logger, error) { |
63 | 63 |
host, port, err := parseAddress(ctx.Config[addressKey]) |
64 | 64 |
if err != nil { |
... | ... |
@@ -154,12 +154,11 @@ func (f *fluentd) Name() string { |
154 | 154 |
return name |
155 | 155 |
} |
156 | 156 |
|
157 |
-// ValidateLogOpt looks for fluentd specific log options fluentd-address & fluentd-tag. |
|
157 |
+// ValidateLogOpt looks for fluentd specific log option fluentd-address. |
|
158 | 158 |
func ValidateLogOpt(cfg map[string]string) error { |
159 | 159 |
for key := range cfg { |
160 | 160 |
switch key { |
161 | 161 |
case "env": |
162 |
- case "fluentd-tag": |
|
163 | 162 |
case "labels": |
164 | 163 |
case "tag": |
165 | 164 |
case addressKey: |
... | ... |
@@ -40,8 +40,7 @@ func init() { |
40 | 40 |
} |
41 | 41 |
|
42 | 42 |
// New creates a gelf logger using the configuration passed in on the |
43 |
-// context. Supported context configuration variables are |
|
44 |
-// gelf-address, & gelf-tag. |
|
43 |
+// context. The supported context configuration variable is gelf-address. |
|
45 | 44 |
func New(ctx logger.Context) (logger.Logger, error) { |
46 | 45 |
// parse gelf address |
47 | 46 |
address, err := parseAddress(ctx.Config["gelf-address"]) |
... | ... |
@@ -153,13 +152,11 @@ func (s *gelfLogger) Name() string { |
153 | 153 |
return name |
154 | 154 |
} |
155 | 155 |
|
156 |
-// ValidateLogOpt looks for gelf specific log options gelf-address, & |
|
157 |
-// gelf-tag. |
|
156 |
+// ValidateLogOpt looks for gelf specific log option gelf-address. |
|
158 | 157 |
func ValidateLogOpt(cfg map[string]string) error { |
159 | 158 |
for key, val := range cfg { |
160 | 159 |
switch key { |
161 | 160 |
case "gelf-address": |
162 |
- case "gelf-tag": |
|
163 | 161 |
case "tag": |
164 | 162 |
case "labels": |
165 | 163 |
case "env": |
... | ... |
@@ -2,9 +2,7 @@ package loggerutils |
2 | 2 |
|
3 | 3 |
import ( |
4 | 4 |
"bytes" |
5 |
- "fmt" |
|
6 | 5 |
|
7 |
- "github.com/Sirupsen/logrus" |
|
8 | 6 |
"github.com/docker/docker/daemon/logger" |
9 | 7 |
"github.com/docker/docker/utils/templates" |
10 | 8 |
) |
... | ... |
@@ -12,7 +10,10 @@ import ( |
12 | 12 |
// ParseLogTag generates a context aware tag for consistency across different |
13 | 13 |
// log drivers based on the context of the running container. |
14 | 14 |
func ParseLogTag(ctx logger.Context, defaultTemplate string) (string, error) { |
15 |
- tagTemplate := lookupTagTemplate(ctx, defaultTemplate) |
|
15 |
+ tagTemplate := ctx.Config["tag"] |
|
16 |
+ if tagTemplate == "" { |
|
17 |
+ tagTemplate = defaultTemplate |
|
18 |
+ } |
|
16 | 19 |
|
17 | 20 |
tmpl, err := templates.NewParse("log-tag", tagTemplate) |
18 | 21 |
if err != nil { |
... | ... |
@@ -25,22 +26,3 @@ func ParseLogTag(ctx logger.Context, defaultTemplate string) (string, error) { |
25 | 25 |
|
26 | 26 |
return buf.String(), nil |
27 | 27 |
} |
28 |
- |
|
29 |
-func lookupTagTemplate(ctx logger.Context, defaultTemplate string) string { |
|
30 |
- tagTemplate := ctx.Config["tag"] |
|
31 |
- |
|
32 |
- deprecatedConfigs := []string{"syslog-tag", "gelf-tag", "fluentd-tag"} |
|
33 |
- for i := 0; tagTemplate == "" && i < len(deprecatedConfigs); i++ { |
|
34 |
- cfg := deprecatedConfigs[i] |
|
35 |
- if ctx.Config[cfg] != "" { |
|
36 |
- tagTemplate = ctx.Config[cfg] |
|
37 |
- logrus.Warn(fmt.Sprintf("Using log tag from deprecated log-opt '%s'. Please use: --log-opt tag=\"%s\"", cfg, tagTemplate)) |
|
38 |
- } |
|
39 |
- } |
|
40 |
- |
|
41 |
- if tagTemplate == "" { |
|
42 |
- tagTemplate = defaultTemplate |
|
43 |
- } |
|
44 |
- |
|
45 |
- return tagTemplate |
|
46 |
-} |
... | ... |
@@ -18,24 +18,6 @@ func TestParseLogTag(t *testing.T) { |
18 | 18 |
assertTag(t, e, tag, "test-image/test-container/container-ab") |
19 | 19 |
} |
20 | 20 |
|
21 |
-func TestParseLogTagSyslogTag(t *testing.T) { |
|
22 |
- ctx := buildContext(map[string]string{"syslog-tag": "{{.ImageName}}/{{.Name}}/{{.ID}}"}) |
|
23 |
- tag, e := ParseLogTag(ctx, "{{.ID}}") |
|
24 |
- assertTag(t, e, tag, "test-image/test-container/container-ab") |
|
25 |
-} |
|
26 |
- |
|
27 |
-func TestParseLogTagGelfTag(t *testing.T) { |
|
28 |
- ctx := buildContext(map[string]string{"gelf-tag": "{{.ImageName}}/{{.Name}}/{{.ID}}"}) |
|
29 |
- tag, e := ParseLogTag(ctx, "{{.ID}}") |
|
30 |
- assertTag(t, e, tag, "test-image/test-container/container-ab") |
|
31 |
-} |
|
32 |
- |
|
33 |
-func TestParseLogTagFluentdTag(t *testing.T) { |
|
34 |
- ctx := buildContext(map[string]string{"fluentd-tag": "{{.ImageName}}/{{.Name}}/{{.ID}}"}) |
|
35 |
- tag, e := ParseLogTag(ctx, "{{.ID}}") |
|
36 |
- assertTag(t, e, tag, "test-image/test-container/container-ab") |
|
37 |
-} |
|
38 |
- |
|
39 | 21 |
// Helpers |
40 | 22 |
|
41 | 23 |
func buildContext(cfg map[string]string) logger.Context { |
... | ... |
@@ -89,7 +89,7 @@ func rfc5424microformatterWithAppNameAsTag(p syslog.Priority, hostname, tag, con |
89 | 89 |
|
90 | 90 |
// New creates a syslog logger using the configuration passed in on |
91 | 91 |
// the context. Supported context configuration variables are |
92 |
-// syslog-address, syslog-facility, syslog-format, syslog-tag. |
|
92 |
+// syslog-address, syslog-facility, syslog-format. |
|
93 | 93 |
func New(ctx logger.Context) (logger.Logger, error) { |
94 | 94 |
tag, err := loggerutils.ParseLogTag(ctx, "{{.ID}}") |
95 | 95 |
if err != nil { |
... | ... |
@@ -184,7 +184,7 @@ func parseAddress(address string) (string, string, error) { |
184 | 184 |
} |
185 | 185 |
|
186 | 186 |
// ValidateLogOpt looks for syslog specific log options |
187 |
-// syslog-address, syslog-facility, & syslog-tag. |
|
187 |
+// syslog-address, syslog-facility. |
|
188 | 188 |
func ValidateLogOpt(cfg map[string]string) error { |
189 | 189 |
for key := range cfg { |
190 | 190 |
switch key { |
... | ... |
@@ -192,7 +192,6 @@ func ValidateLogOpt(cfg map[string]string) error { |
192 | 192 |
case "labels": |
193 | 193 |
case "syslog-address": |
194 | 194 |
case "syslog-facility": |
195 |
- case "syslog-tag": |
|
196 | 195 |
case "syslog-tls-ca-cert": |
197 | 196 |
case "syslog-tls-cert": |
198 | 197 |
case "syslog-tls-key": |
... | ... |
@@ -64,8 +64,3 @@ Apr 1 15:22:17 ip-10-27-39-73 docker/logtester.1234[45499]: + exec app |
64 | 64 |
Apr 1 15:22:17 ip-10-27-39-73 docker/logtester.1234[45499]: 2016-04-01 15:22:17.075416751 +0000 UTC stderr msg: 1 |
65 | 65 |
``` |
66 | 66 |
|
67 |
- |
|
68 |
- |
|
69 |
->**Note**:The driver specific log options `syslog-tag`, `fluentd-tag` and |
|
70 |
->`gelf-tag` still work for backwards compatibility. However, going forward you |
|
71 |
->should standardize on using the generic `tag` log option instead. |
... | ... |
@@ -73,7 +73,7 @@ variants: |
73 | 73 |
### Driver Specific Log Tags |
74 | 74 |
**Deprecated In Release: v1.9** |
75 | 75 |
|
76 |
-**Target For Removal In Release: v1.11** |
|
76 |
+**Removed In Release: v1.12** |
|
77 | 77 |
|
78 | 78 |
Log tags are now generated in a standard way across different logging drivers. |
79 | 79 |
Because of which, the driver specific log tag options `syslog-tag`, `gelf-tag` and |