| 17 | ) |
| 18 | |
| 19 | func newLogWriter() (logger.Writer, error) { |
| 20 | sec := conf.File.Section("log.gorm") |
| 21 | w, err := log.NewFileWriter( |
| 22 | filepath.Join(conf.Log.RootPath, "gorm.log"), |
| 23 | log.FileRotationConfig{ |
| 24 | Rotate: sec.Key("ROTATE").MustBool(true), |
| 25 | Daily: sec.Key("ROTATE_DAILY").MustBool(true), |
| 26 | MaxSize: sec.Key("MAX_SIZE").MustInt64(100) * 1024 * 1024, |
| 27 | MaxDays: sec.Key("MAX_DAYS").MustInt64(3), |
| 28 | }, |
| 29 | ) |
| 30 | if err != nil { |
| 31 | return nil, errors.Wrap(err, `create "gorm.log"`) |
| 32 | } |
| 33 | return &dbutil.Logger{Writer: w}, nil |
| 34 | } |
| 35 | |
| 36 | // Tables is the list of struct-to-table mappings. |
| 37 | // |