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
|
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
|
FallbackTLSConfig *tls.Config // config for fallback TLS connection (only used if UseFallBackTLS is true)-- nil disables TLS
|
||||||
Logger Logger
|
Logger Logger
|
||||||
LogLevel int
|
LogLevel LogLevel
|
||||||
Dial DialFunc
|
Dial DialFunc
|
||||||
RuntimeParams map[string]string // Run-time parameters to set on connection as session default values (e.g. search_path or application_name)
|
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.
|
OnNotice NoticeHandler // Callback function called when a notice response is received.
|
||||||
@@ -123,7 +123,7 @@ type Conn struct {
|
|||||||
channels map[string]struct{}
|
channels map[string]struct{}
|
||||||
notifications []*Notification
|
notifications []*Notification
|
||||||
logger Logger
|
logger Logger
|
||||||
logLevel int
|
logLevel LogLevel
|
||||||
fp *fastpath
|
fp *fastpath
|
||||||
poolResetCount int
|
poolResetCount int
|
||||||
preallocatedRows []Rows
|
preallocatedRows []Rows
|
||||||
@@ -1609,7 +1609,7 @@ func (c *Conn) unlock() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) shouldLog(lvl int) bool {
|
func (c *Conn) shouldLog(lvl LogLevel) bool {
|
||||||
return c.logger != nil && c.logLevel >= lvl
|
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
|
// SetLogLevel replaces the current log level and returns the previous log
|
||||||
// level.
|
// level.
|
||||||
func (c *Conn) SetLogLevel(lvl int) (int, error) {
|
func (c *Conn) SetLogLevel(lvl LogLevel) (LogLevel, error) {
|
||||||
oldLvl := c.logLevel
|
oldLvl := c.logLevel
|
||||||
|
|
||||||
if lvl < LogLevelNone || lvl > LogLevelTrace {
|
if lvl < LogLevelNone || lvl > LogLevelTrace {
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ type ConnPool struct {
|
|||||||
resetCount int
|
resetCount int
|
||||||
afterConnect func(*Conn) error
|
afterConnect func(*Conn) error
|
||||||
logger Logger
|
logger Logger
|
||||||
logLevel int
|
logLevel LogLevel
|
||||||
closed bool
|
closed bool
|
||||||
preparedStatements map[string]*PreparedStatement
|
preparedStatements map[string]*PreparedStatement
|
||||||
acquireTimeout time.Duration
|
acquireTimeout time.Duration
|
||||||
|
|||||||
Reference in New Issue
Block a user