feat: support for disable mon logs like sqlx (#3606)
Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
This commit is contained in:
@@ -9,7 +9,11 @@ import (
|
||||
|
||||
const defaultTimeout = time.Second * 3
|
||||
|
||||
var slowThreshold = syncx.ForAtomicDuration(defaultSlowThreshold)
|
||||
var (
|
||||
slowThreshold = syncx.ForAtomicDuration(defaultSlowThreshold)
|
||||
logMon = syncx.ForAtomicBool(true)
|
||||
logSlowMon = syncx.ForAtomicBool(true)
|
||||
)
|
||||
|
||||
type (
|
||||
options = mopt.ClientOptions
|
||||
@@ -18,6 +22,17 @@ type (
|
||||
Option func(opts *options)
|
||||
)
|
||||
|
||||
// DisableLog disables logging of mongo command, includes info and slow logs.
|
||||
func DisableLog() {
|
||||
logMon.Set(false)
|
||||
logSlowMon.Set(false)
|
||||
}
|
||||
|
||||
// DisableInfoLog disables info logging of mongo command, but keeps slow logs.
|
||||
func DisableInfoLog() {
|
||||
logMon.Set(false)
|
||||
}
|
||||
|
||||
// SetSlowThreshold sets the slow threshold.
|
||||
func SetSlowThreshold(threshold time.Duration) {
|
||||
slowThreshold.Set(threshold)
|
||||
|
||||
Reference in New Issue
Block a user