From 038060776bdd85d61c2138e4ace990c2bfc742be Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 23 Mar 2019 11:22:47 -0500 Subject: [PATCH] Use LogLevel type instead of int for conn config Technically, this is a change in the public interface. But it seems extremely unlikely that it would cause any issues (and any that do appear would be trivial to fix). fixes #516 --- conn.go | 8 ++++---- conn_pool.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conn.go b/conn.go index 1693d159..d500b132 100644 --- a/conn.go +++ b/conn.go @@ -72,7 +72,7 @@ type ConnConfig struct { UseFallbackTLS bool // Try FallbackTLSConfig if connecting with TLSConfig fails. Used for preferring TLS, but allowing unencrypted, or vice-versa FallbackTLSConfig *tls.Config // config for fallback TLS connection (only used if UseFallBackTLS is true)-- nil disables TLS Logger Logger - LogLevel int + LogLevel LogLevel Dial DialFunc RuntimeParams map[string]string // Run-time parameters to set on connection as session default values (e.g. search_path or application_name) OnNotice NoticeHandler // Callback function called when a notice response is received. @@ -123,7 +123,7 @@ type Conn struct { channels map[string]struct{} notifications []*Notification logger Logger - logLevel int + logLevel LogLevel fp *fastpath poolResetCount int preallocatedRows []Rows @@ -1609,7 +1609,7 @@ func (c *Conn) unlock() error { return nil } -func (c *Conn) shouldLog(lvl int) bool { +func (c *Conn) shouldLog(lvl LogLevel) bool { return c.logger != nil && c.logLevel >= lvl } @@ -1633,7 +1633,7 @@ func (c *Conn) SetLogger(logger Logger) Logger { // SetLogLevel replaces the current log level and returns the previous log // level. -func (c *Conn) SetLogLevel(lvl int) (int, error) { +func (c *Conn) SetLogLevel(lvl LogLevel) (LogLevel, error) { oldLvl := c.logLevel if lvl < LogLevelNone || lvl > LogLevelTrace { diff --git a/conn_pool.go b/conn_pool.go index 77450dba..af4c879e 100644 --- a/conn_pool.go +++ b/conn_pool.go @@ -28,7 +28,7 @@ type ConnPool struct { resetCount int afterConnect func(*Conn) error logger Logger - logLevel int + logLevel LogLevel closed bool preparedStatements map[string]*PreparedStatement acquireTimeout time.Duration