Skip to content

Commit

Permalink
Change WARN log level to INFO
Browse files Browse the repository at this point in the history
  • Loading branch information
desa committed Nov 8, 2017
1 parent ab66b19 commit 7df7f6d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 100 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- [#1644](https://github.com/influxdata/kapacitor/issues/1644): Add support for [JSON lines](https://en.wikipedia.org/wiki/JSON_Streaming#Line_delimited_JSON) for steaming HTTP logs.
- [#1637](https://github.com/influxdata/kapacitor/issues/1637): Add new node Sideload, that allows loading data from files into the stream of data. Data can be loaded using a hierarchy.
- [#1667](https://github.com/influxdata/kapacitor/pull/1667): Promote Alert API to stable v1 path.
- [#1668](https://github.com/influxdata/kapacitor/pull/1668): Change WARN level logs to INFO level.

### Bugfixes

Expand Down
2 changes: 1 addition & 1 deletion cmd/kapacitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,7 @@ func doDelete(args []string) error {

// Level
func levelUsage() {
var u = `Usage: kapacitor level (debug|info|warn|error)
var u = `Usage: kapacitor level (debug|info|error)
Sets the logging level on the kapacitord server.
`
Expand Down
21 changes: 7 additions & 14 deletions services/diagnostic/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ func (h *KapacitorHandler) LogPointData(level, prefix string, point edge.PointMe
log = h.l.Error
case "DEBUG":
log = h.l.Debug
case "WARN":
log = h.l.Warn
default:
log = h.l.Info
}
Expand All @@ -278,8 +276,6 @@ func (h *KapacitorHandler) LogBatchData(level, prefix string, batch edge.Buffere
log = h.l.Error
case "DEBUG":
log = h.l.Debug
case "WARN":
log = h.l.Warn
default:
log = h.l.Info
}
Expand Down Expand Up @@ -492,7 +488,7 @@ type SlackHandler struct {
}

func (h *SlackHandler) InsecureSkipVerify() {
h.l.Warn("service is configured to skip ssl verification")
h.l.Info("service is configured to skip ssl verification")
}

func (h *SlackHandler) Error(msg string, err error) {
Expand Down Expand Up @@ -921,11 +917,11 @@ type NoAuthHandler struct {
}

func (h *NoAuthHandler) FakedUserAuthentication(username string) {
h.l.Warn("using noauth auth backend. Faked Authentication for user", String("user", username))
h.l.Info("using noauth auth backend. Faked Authentication for user", String("user", username))
}

func (h *NoAuthHandler) FakedSubscriptionUserToken() {
h.l.Warn("using noauth auth backend. Faked authentication for subscription user token")
h.l.Info("using noauth auth backend. Faked authentication for subscription user token")
}

// Stats handler
Expand Down Expand Up @@ -979,7 +975,7 @@ func (h *InfluxDBHandler) WithUDPContext(db string, rp string) udp.Diagnostic {
}

func (h *InfluxDBHandler) InsecureSkipVerify(urls []string) {
h.l.Warn("using InsecureSkipVerify when connecting to InfluxDB; this is insecure", Strings("urls", urls))
h.l.Info("using InsecureSkipVerify when connecting to InfluxDB; this is insecure", Strings("urls", urls))
}

func (h *InfluxDBHandler) UnlinkingSubscriptions(cluster string) {
Expand Down Expand Up @@ -1052,7 +1048,7 @@ func (h *ScraperHandler) Warn(ctx ...interface{}) {
defer h.buf.Reset()
fmt.Fprint(h.buf, ctx...)

h.l.Warn(h.buf.String())
h.l.Info(h.buf.String())
}

func (h *ScraperHandler) Warnln(ctx ...interface{}) {
Expand All @@ -1061,11 +1057,11 @@ func (h *ScraperHandler) Warnln(ctx ...interface{}) {
defer h.buf.Reset()
fmt.Fprintln(h.buf, ctx...)

h.l.Warn(strconv.Quote(h.buf.String()))
h.l.Info(strconv.Quote(h.buf.String()))
}

func (h *ScraperHandler) Warnf(s string, ctx ...interface{}) {
h.l.Warn(fmt.Sprintf(s, ctx...))
h.l.Info(fmt.Sprintf(s, ctx...))
}

func (h *ScraperHandler) Error(ctx ...interface{}) {
Expand Down Expand Up @@ -1161,7 +1157,6 @@ const (
llDebug
llError
llInfo
llWarn
)

type StaticLevelHandler struct {
Expand All @@ -1177,8 +1172,6 @@ func (h *StaticLevelHandler) Write(buf []byte) (int, error) {
h.l.Error(string(buf))
case llInfo:
h.l.Info(string(buf))
case llWarn:
h.l.Warn(string(buf))
default:
return 0, errors.New("invalid log level")
}
Expand Down
23 changes: 0 additions & 23 deletions services/diagnostic/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ type Level int
const (
DebugLevel Level = iota
InfoLevel
WarnLevel
ErrorLevel
)

type Logger interface {
Error(msg string, ctx ...Field)
Warn(msg string, ctx ...Field)
Debug(msg string, ctx ...Field)
Info(msg string, ctx ...Field)
With(ctx ...Field) Logger
Expand Down Expand Up @@ -54,12 +52,6 @@ func (l *MultiLogger) Error(msg string, ctx ...Field) {
}
}

func (l *MultiLogger) Warn(msg string, ctx ...Field) {
for _, logger := range l.loggers {
logger.Warn(msg, ctx...)
}
}

func (l *MultiLogger) Debug(msg string, ctx ...Field) {
for _, logger := range l.loggers {
logger.Debug(msg, ctx...)
Expand Down Expand Up @@ -141,15 +133,6 @@ func (l *ServerLogger) Debug(msg string, ctx ...Field) {
}
}

func (l *ServerLogger) Warn(msg string, ctx ...Field) {
l.levelMu.RLock()
logLine := l.levelF(WarnLevel)
l.levelMu.RUnlock()
if logLine {
l.Log(time.Now(), "warn", msg, ctx)
}
}

func (l *ServerLogger) Info(msg string, ctx ...Field) {
l.levelMu.RLock()
logLine := l.levelF(InfoLevel)
Expand Down Expand Up @@ -178,12 +161,6 @@ func (s *sessionsLogger) Error(msg string, ctx ...Field) {
})
}

func (s *sessionsLogger) Warn(msg string, ctx ...Field) {
s.store.Each(func(sn *Session) {
sn.Warn(msg, s.context, ctx)
})
}

func (s *sessionsLogger) Debug(msg string, ctx ...Field) {
s.store.Each(func(sn *Session) {
sn.Debug(msg, s.context, ctx)
Expand Down
51 changes: 0 additions & 51 deletions services/diagnostic/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,6 @@ func TestLogger_SetLeveF(t *testing.T) {
t.Fatal("expected info log")
return
}
buf.Reset()
l.Warn(msg)
logLine = buf.String()
if logLine == "" {
t.Fatal("expected warn log")
return
}
l.Error(msg)
logLine = buf.String()
buf.Reset()
Expand All @@ -354,44 +347,6 @@ func TestLogger_SetLeveF(t *testing.T) {
return
}
buf.Reset()
l.Warn(msg)
logLine = buf.String()
if logLine == "" {
t.Fatal("expected warn log")
return
}
l.Error(msg)
logLine = buf.String()
buf.Reset()
if logLine == "" {
t.Fatal("expected error log")
return
}

l.SetLevelF(func(lvl diagnostic.Level) bool {
return lvl >= diagnostic.WarnLevel
})
l.Debug(msg)
logLine = buf.String()
buf.Reset()
if logLine != "" {
t.Fatal("expected no debug log")
return
}
l.Info(msg)
logLine = buf.String()
buf.Reset()
if logLine != "" {
t.Fatal("expected no info log")
return
}
buf.Reset()
l.Warn(msg)
logLine = buf.String()
if logLine == "" {
t.Fatal("expected warn log")
return
}
l.Error(msg)
logLine = buf.String()
buf.Reset()
Expand All @@ -418,12 +373,6 @@ func TestLogger_SetLeveF(t *testing.T) {
return
}
buf.Reset()
l.Warn(msg)
logLine = buf.String()
if logLine != "" {
t.Fatal("expected no warn log")
return
}
l.Error(msg)
logLine = buf.String()
buf.Reset()
Expand Down
6 changes: 1 addition & 5 deletions services/diagnostic/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s *Service) SetLogLevelFromName(lvl string) error {
defer s.levelMu.Unlock()
level := strings.ToUpper(lvl)
switch level {
case "INFO", "ERROR", "WARN", "DEBUG":
case "INFO", "ERROR", "DEBUG":
s.level = level
default:
return errors.New("invalid log level")
Expand All @@ -69,8 +69,6 @@ func logLevelFromName(lvl string) Level {
level = InfoLevel
case "ERROR", "error":
level = ErrorLevel
case "WARN", "warn":
level = WarnLevel
case "DEBUG", "debug":
level = DebugLevel
}
Expand Down Expand Up @@ -418,8 +416,6 @@ func (s *Service) NewStaticLevelHandler(level string, service string) (*StaticLe
ll = llError
case "info":
ll = llInfo
case "warn":
ll = llWarn
default:
ll = llInvalid
}
Expand Down
6 changes: 0 additions & 6 deletions services/diagnostic/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ func (s *Session) Error(msg string, context, fields []Field) {
}
}

func (s *Session) Warn(msg string, context, fields []Field) {
if s.level <= WarnLevel && match(s.tags, msg, "warn", context, fields) {
s.Log(time.Now(), "warn", msg, context, fields)
}
}

func (s *Session) Debug(msg string, context, fields []Field) {
if s.level <= DebugLevel && match(s.tags, msg, "debug", context, fields) {
s.Log(time.Now(), "debug", msg, context, fields)
Expand Down

0 comments on commit 7df7f6d

Please sign in to comment.