Przeglądaj źródła

Merge branch 'master' into alerting

bergquist 9 lat temu
rodzic
commit
1771ab032e
5 zmienionych plików z 31 dodań i 24 usunięć
  1. 1 1
      appveyor.yml
  2. 1 11
      pkg/log/log.go
  3. 17 2
      pkg/log/syslog.go
  4. 7 5
      pkg/log/syslog_windows.go
  5. 5 5
      pkg/plugins/dashboards_test.go

+ 1 - 1
appveyor.yml

@@ -14,7 +14,7 @@ install:
   - npm install
   - npm install -g grunt-cli
   # install gcc (needed for sqlite3)
-  - choco install -y mingw -limitoutput
+  - choco install -y --limit-output mingw
   - set PATH=C:\tools\mingw64\bin;%PATH%
   - echo %PATH%
   - echo %GOPATH%

+ 1 - 11
pkg/log/log.go

@@ -180,17 +180,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
 			loggersToClose = append(loggersToClose, fileHandler)
 			handler = fileHandler
 		case "syslog":
-			sysLogHandler := NewSyslog()
-			sysLogHandler.Format = format
-			sysLogHandler.Network = sec.Key("network").MustString("")
-			sysLogHandler.Address = sec.Key("address").MustString("")
-			sysLogHandler.Facility = sec.Key("facility").MustString("local7")
-			sysLogHandler.Tag = sec.Key("tag").MustString("")
-
-			if err := sysLogHandler.Init(); err != nil {
-				Root.Error("Failed to init syslog log handler", "error", err)
-				os.Exit(1)
-			}
+			sysLogHandler := NewSyslog(sec, format)
 
 			loggersToClose = append(loggersToClose, sysLogHandler)
 			handler = sysLogHandler

+ 17 - 2
pkg/log/syslog.go

@@ -5,8 +5,10 @@ package log
 import (
 	"errors"
 	"log/syslog"
+	"os"
 
 	"github.com/inconshreveable/log15"
+	"gopkg.in/ini.v1"
 )
 
 type SysLogHandler struct {
@@ -18,10 +20,23 @@ type SysLogHandler struct {
 	Format   log15.Format
 }
 
-func NewSyslog() *SysLogHandler {
-	return &SysLogHandler{
+func NewSyslog(sec *ini.Section, format log15.Format) *SysLogHandler {
+	handler := &SysLogHandler{
 		Format: log15.LogfmtFormat(),
 	}
+
+	handler.Format = format
+	handler.Network = sec.Key("network").MustString("")
+	handler.Address = sec.Key("address").MustString("")
+	handler.Facility = sec.Key("facility").MustString("local7")
+	handler.Tag = sec.Key("tag").MustString("")
+
+	if err := handler.Init(); err != nil {
+		Root.Error("Failed to init syslog log handler", "error", err)
+		os.Exit(1)
+	}
+
+	return handler
 }
 
 func (sw *SysLogHandler) Init() error {

+ 7 - 5
pkg/log/syslog_windows.go

@@ -2,19 +2,21 @@
 
 package log
 
-import "github.com/inconshreveable/log15"
+import (
+	"github.com/inconshreveable/log15"
+	"gopkg.in/ini.v1"
+)
 
 type SysLogHandler struct {
 }
 
-func NewSyslog() *SysLogHandler {
+func NewSyslog(sec *ini.Section, format log15.Format) *SysLogHandler {
 	return &SysLogHandler{}
 }
 
-func (sw *SysLogHandler) Init() error {
+func (sw *SysLogHandler) Log(r *log15.Record) error {
 	return nil
 }
 
-func (sw *SysLogHandler) Log(r *log15.Record) error {
-	return nil
+func (sw *SysLogHandler) Close() {
 }

+ 5 - 5
pkg/plugins/dashboards_test.go

@@ -41,12 +41,12 @@ func TestPluginDashboards(t *testing.T) {
 
 		Convey("should include installed version info", func() {
 			So(dashboards[0].Title, ShouldEqual, "Nginx Connections")
-			So(dashboards[0].Revision, ShouldEqual, "1.5")
-			So(dashboards[0].InstalledRevision, ShouldEqual, "1.1")
-			So(dashboards[0].InstalledUri, ShouldEqual, "db/nginx-connections")
+			//So(dashboards[0].Revision, ShouldEqual, "1.5")
+			//So(dashboards[0].InstalledRevision, ShouldEqual, "1.1")
+			//So(dashboards[0].InstalledUri, ShouldEqual, "db/nginx-connections")
 
-			So(dashboards[1].Revision, ShouldEqual, "2.0")
-			So(dashboards[1].InstalledRevision, ShouldEqual, "")
+			//So(dashboards[1].Revision, ShouldEqual, "2.0")
+			//So(dashboards[1].InstalledRevision, ShouldEqual, "")
 		})
 	})