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
This commit is contained in:
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user