github.com/wfusion/gofusion@v1.1.14/mongo/types.go (about) 1 package mongo 2 3 import ( 4 "reflect" 5 6 "github.com/wfusion/gofusion/common/infra/drivers/mongo" 7 "github.com/wfusion/gofusion/common/utils" 8 "github.com/wfusion/gofusion/log" 9 10 mgoEvt "go.mongodb.org/mongo-driver/event" 11 ) 12 13 const ( 14 ErrDuplicatedName utils.Error = "duplicated mongo name" 15 ) 16 17 var ( 18 customLoggerType = reflect.TypeOf((*customLogger)(nil)).Elem() 19 ) 20 21 // Conf 22 //nolint: revive // struct tag too long issue 23 type Conf struct { 24 mongo.Option `yaml:",inline" json:",inline" toml:",inline"` 25 EnableLogger bool `yaml:"enable_logger" json:"enable_logger" toml:"enable_logger" default:"false"` 26 LoggerConfig struct { 27 Logger string `yaml:"logger" json:"logger" toml:"logger" default:"github.com/wfusion/gofusion/log/customlogger.mongoLogger"` 28 LogInstance string `yaml:"log_instance" json:"log_instance" toml:"log_instance" default:"default"` 29 LoggableCommands []string `yaml:"loggable_commands" json:"loggable_commands" toml:"loggable_commands" default:"[insert,find,update,delete,aggregate,distinct,count,findAndModify]"` 30 } `yaml:"logger_config" json:"logger_config" toml:"logger_config"` 31 } 32 33 type customLogger interface { 34 logger 35 Init(log log.Loggable, appName, name string) 36 } 37 38 type logger interface { 39 GetMonitor() *mgoEvt.CommandMonitor 40 }