diff --git a/logger.go b/logger.go index 9d65fb3..2b7137d 100644 --- a/logger.go +++ b/logger.go @@ -14,12 +14,18 @@ type EventReceiver struct { // Event receives a simple notification when various events occur func (n *EventReceiver) Event(eventName string) { + if n.s.LogLevel == 0 { + return + } n.logger.WithCallDepth(2).V(1).Info(eventName) } // EventKv receives a notification when various events occur along with // optional key/value data func (n *EventReceiver) EventKv(eventName string, kvs map[string]string) { + if n.s.LogLevel == 0 { + return + } n.logger.WithCallDepth(2).V(1).Info(eventName) } @@ -38,21 +44,19 @@ func (n *EventReceiver) Timing(eventName string, nanoseconds int64) { // TimingKv receives the time an event took to happen along with optional key/value data func (n *EventReceiver) TimingKv(eventName string, nanoseconds int64, kvs map[string]string) { + if n.s.LogLevel == 0 { + return + } sql := kvs["sql"] sp := strings.Index(sql, " ") if sp != -1 { - query := sql[:sp] if n.s.LogLevel > 1 { n.logger.WithCallDepth(3).V(1).Info(sql) } else { if len(sql) > 50 { sql = sql[:50] + "..." } - if query == "SELECT" && n.s.LogLevel > 0 { - n.logger.WithCallDepth(3).V(1).Info(sql) - } else { - n.logger.WithCallDepth(3).V(1).Info(sql) - } + n.logger.WithCallDepth(3).V(1).Info(sql) } } }