浏览代码

Merge pull request #22620 from yongtang/05092016-remove-deprecated-driver-specific-log-tags

Remove deprecated driver specific log tags
Vincent Demeester 9 年之前
父节点
当前提交
7fd9f9964a

+ 3 - 4
daemon/logger/fluentd/fluentd.go

@@ -57,8 +57,8 @@ func init() {
 }
 
 // New creates a fluentd logger using the configuration passed in on
-// the context. Supported context configuration variables are
-// fluentd-address & fluentd-tag.
+// the context. The supported context configuration variable is
+// fluentd-address.
 func New(ctx logger.Context) (logger.Logger, error) {
 	host, port, err := parseAddress(ctx.Config[addressKey])
 	if err != nil {
@@ -154,12 +154,11 @@ func (f *fluentd) Name() string {
 	return name
 }
 
-// ValidateLogOpt looks for fluentd specific log options fluentd-address & fluentd-tag.
+// ValidateLogOpt looks for fluentd specific log option fluentd-address.
 func ValidateLogOpt(cfg map[string]string) error {
 	for key := range cfg {
 		switch key {
 		case "env":
-		case "fluentd-tag":
 		case "labels":
 		case "tag":
 		case addressKey:

+ 2 - 5
daemon/logger/gelf/gelf.go

@@ -40,8 +40,7 @@ func init() {
 }
 
 // New creates a gelf logger using the configuration passed in on the
-// context. Supported context configuration variables are
-// gelf-address, & gelf-tag.
+// context. The supported context configuration variable is gelf-address.
 func New(ctx logger.Context) (logger.Logger, error) {
 	// parse gelf address
 	address, err := parseAddress(ctx.Config["gelf-address"])
@@ -153,13 +152,11 @@ func (s *gelfLogger) Name() string {
 	return name
 }
 
-// ValidateLogOpt looks for gelf specific log options gelf-address, &
-// gelf-tag.
+// ValidateLogOpt looks for gelf specific log option gelf-address.
 func ValidateLogOpt(cfg map[string]string) error {
 	for key, val := range cfg {
 		switch key {
 		case "gelf-address":
-		case "gelf-tag":
 		case "tag":
 		case "labels":
 		case "env":

+ 4 - 22
daemon/logger/loggerutils/log_tag.go

@@ -2,9 +2,7 @@ package loggerutils
 
 import (
 	"bytes"
-	"fmt"
 
-	"github.com/Sirupsen/logrus"
 	"github.com/docker/docker/daemon/logger"
 	"github.com/docker/docker/utils/templates"
 )
@@ -12,7 +10,10 @@ import (
 // ParseLogTag generates a context aware tag for consistency across different
 // log drivers based on the context of the running container.
 func ParseLogTag(ctx logger.Context, defaultTemplate string) (string, error) {
-	tagTemplate := lookupTagTemplate(ctx, defaultTemplate)
+	tagTemplate := ctx.Config["tag"]
+	if tagTemplate == "" {
+		tagTemplate = defaultTemplate
+	}
 
 	tmpl, err := templates.NewParse("log-tag", tagTemplate)
 	if err != nil {
@@ -25,22 +26,3 @@ func ParseLogTag(ctx logger.Context, defaultTemplate string) (string, error) {
 
 	return buf.String(), nil
 }
-
-func lookupTagTemplate(ctx logger.Context, defaultTemplate string) string {
-	tagTemplate := ctx.Config["tag"]
-
-	deprecatedConfigs := []string{"syslog-tag", "gelf-tag", "fluentd-tag"}
-	for i := 0; tagTemplate == "" && i < len(deprecatedConfigs); i++ {
-		cfg := deprecatedConfigs[i]
-		if ctx.Config[cfg] != "" {
-			tagTemplate = ctx.Config[cfg]
-			logrus.Warn(fmt.Sprintf("Using log tag from deprecated log-opt '%s'. Please use: --log-opt tag=\"%s\"", cfg, tagTemplate))
-		}
-	}
-
-	if tagTemplate == "" {
-		tagTemplate = defaultTemplate
-	}
-
-	return tagTemplate
-}

+ 0 - 18
daemon/logger/loggerutils/log_tag_test.go

@@ -18,24 +18,6 @@ func TestParseLogTag(t *testing.T) {
 	assertTag(t, e, tag, "test-image/test-container/container-ab")
 }
 
-func TestParseLogTagSyslogTag(t *testing.T) {
-	ctx := buildContext(map[string]string{"syslog-tag": "{{.ImageName}}/{{.Name}}/{{.ID}}"})
-	tag, e := ParseLogTag(ctx, "{{.ID}}")
-	assertTag(t, e, tag, "test-image/test-container/container-ab")
-}
-
-func TestParseLogTagGelfTag(t *testing.T) {
-	ctx := buildContext(map[string]string{"gelf-tag": "{{.ImageName}}/{{.Name}}/{{.ID}}"})
-	tag, e := ParseLogTag(ctx, "{{.ID}}")
-	assertTag(t, e, tag, "test-image/test-container/container-ab")
-}
-
-func TestParseLogTagFluentdTag(t *testing.T) {
-	ctx := buildContext(map[string]string{"fluentd-tag": "{{.ImageName}}/{{.Name}}/{{.ID}}"})
-	tag, e := ParseLogTag(ctx, "{{.ID}}")
-	assertTag(t, e, tag, "test-image/test-container/container-ab")
-}
-
 // Helpers
 
 func buildContext(cfg map[string]string) logger.Context {

+ 2 - 3
daemon/logger/syslog/syslog.go

@@ -89,7 +89,7 @@ func rfc5424microformatterWithAppNameAsTag(p syslog.Priority, hostname, tag, con
 
 // New creates a syslog logger using the configuration passed in on
 // the context. Supported context configuration variables are
-// syslog-address, syslog-facility, syslog-format,  syslog-tag.
+// syslog-address, syslog-facility, syslog-format.
 func New(ctx logger.Context) (logger.Logger, error) {
 	tag, err := loggerutils.ParseLogTag(ctx, "{{.ID}}")
 	if err != nil {
@@ -184,7 +184,7 @@ func parseAddress(address string) (string, string, error) {
 }
 
 // ValidateLogOpt looks for syslog specific log options
-// syslog-address, syslog-facility, & syslog-tag.
+// syslog-address, syslog-facility.
 func ValidateLogOpt(cfg map[string]string) error {
 	for key := range cfg {
 		switch key {
@@ -192,7 +192,6 @@ func ValidateLogOpt(cfg map[string]string) error {
 		case "labels":
 		case "syslog-address":
 		case "syslog-facility":
-		case "syslog-tag":
 		case "syslog-tls-ca-cert":
 		case "syslog-tls-cert":
 		case "syslog-tls-key":

+ 0 - 5
docs/admin/logging/log_tags.md

@@ -64,8 +64,3 @@ Apr  1 15:22:17 ip-10-27-39-73 docker/logtester.1234[45499]: + exec app
 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
 ```
 
-
-
->**Note**:The driver specific log options `syslog-tag`, `fluentd-tag` and
->`gelf-tag` still work for backwards compatibility. However, going forward you
->should standardize on using the generic `tag` log option instead.

+ 1 - 1
docs/deprecated.md

@@ -73,7 +73,7 @@ variants:
 ### Driver Specific Log Tags
 **Deprecated In Release: v1.9**
 
-**Target For Removal In Release: v1.11**
+**Removed In Release: v1.12**
 
 Log tags are now generated in a standard way across different logging drivers.
 Because of which, the driver specific log tag options `syslog-tag`, `gelf-tag` and