Commit 1771ab03 by bergquist

Merge branch 'master' into alerting

parents 8ec311ad 8b2f6fff
...@@ -14,7 +14,7 @@ install: ...@@ -14,7 +14,7 @@ install:
- npm install - npm install
- npm install -g grunt-cli - npm install -g grunt-cli
# install gcc (needed for sqlite3) # install gcc (needed for sqlite3)
- choco install -y mingw -limitoutput - choco install -y --limit-output mingw
- set PATH=C:\tools\mingw64\bin;%PATH% - set PATH=C:\tools\mingw64\bin;%PATH%
- echo %PATH% - echo %PATH%
- echo %GOPATH% - echo %GOPATH%
......
...@@ -180,17 +180,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) { ...@@ -180,17 +180,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
loggersToClose = append(loggersToClose, fileHandler) loggersToClose = append(loggersToClose, fileHandler)
handler = fileHandler handler = fileHandler
case "syslog": case "syslog":
sysLogHandler := NewSyslog() sysLogHandler := NewSyslog(sec, format)
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)
}
loggersToClose = append(loggersToClose, sysLogHandler) loggersToClose = append(loggersToClose, sysLogHandler)
handler = sysLogHandler handler = sysLogHandler
......
...@@ -5,8 +5,10 @@ package log ...@@ -5,8 +5,10 @@ package log
import ( import (
"errors" "errors"
"log/syslog" "log/syslog"
"os"
"github.com/inconshreveable/log15" "github.com/inconshreveable/log15"
"gopkg.in/ini.v1"
) )
type SysLogHandler struct { type SysLogHandler struct {
...@@ -18,10 +20,23 @@ type SysLogHandler struct { ...@@ -18,10 +20,23 @@ type SysLogHandler struct {
Format log15.Format Format log15.Format
} }
func NewSyslog() *SysLogHandler { func NewSyslog(sec *ini.Section, format log15.Format) *SysLogHandler {
return &SysLogHandler{ handler := &SysLogHandler{
Format: log15.LogfmtFormat(), 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 { func (sw *SysLogHandler) Init() error {
......
...@@ -2,19 +2,21 @@ ...@@ -2,19 +2,21 @@
package log package log
import "github.com/inconshreveable/log15" import (
"github.com/inconshreveable/log15"
"gopkg.in/ini.v1"
)
type SysLogHandler struct { type SysLogHandler struct {
} }
func NewSyslog() *SysLogHandler { func NewSyslog(sec *ini.Section, format log15.Format) *SysLogHandler {
return &SysLogHandler{} return &SysLogHandler{}
} }
func (sw *SysLogHandler) Init() error { func (sw *SysLogHandler) Log(r *log15.Record) error {
return nil return nil
} }
func (sw *SysLogHandler) Log(r *log15.Record) error { func (sw *SysLogHandler) Close() {
return nil
} }
...@@ -41,12 +41,12 @@ func TestPluginDashboards(t *testing.T) { ...@@ -41,12 +41,12 @@ func TestPluginDashboards(t *testing.T) {
Convey("should include installed version info", func() { Convey("should include installed version info", func() {
So(dashboards[0].Title, ShouldEqual, "Nginx Connections") So(dashboards[0].Title, ShouldEqual, "Nginx Connections")
So(dashboards[0].Revision, ShouldEqual, "1.5") //So(dashboards[0].Revision, ShouldEqual, "1.5")
So(dashboards[0].InstalledRevision, ShouldEqual, "1.1") //So(dashboards[0].InstalledRevision, ShouldEqual, "1.1")
So(dashboards[0].InstalledUri, ShouldEqual, "db/nginx-connections") //So(dashboards[0].InstalledUri, ShouldEqual, "db/nginx-connections")
So(dashboards[1].Revision, ShouldEqual, "2.0") //So(dashboards[1].Revision, ShouldEqual, "2.0")
So(dashboards[1].InstalledRevision, ShouldEqual, "") //So(dashboards[1].InstalledRevision, ShouldEqual, "")
}) })
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment