i18n: logs in database script
This commit is contained in:
parent
756769335f
commit
92cbc9f312
3 changed files with 6 additions and 6 deletions
|
@ -15,12 +15,12 @@ var availableScripts = make(map[string]DBScript)
|
|||
|
||||
func RunDBScript(name string, ctx context.Context) error {
|
||||
if script, ok := availableScripts[name]; ok {
|
||||
util.Log().Info("开始执行数据库脚本 [%s]", name)
|
||||
util.Log().Info("Start executing database script %q.", name)
|
||||
script.Run(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("数据库脚本 [%s] 不存在", name)
|
||||
return fmt.Errorf("Database script %q not exist.", name)
|
||||
}
|
||||
|
||||
func Register(name string, script DBScript) {
|
||||
|
|
|
@ -14,7 +14,7 @@ func (script ResetAdminPassword) Run(ctx context.Context) {
|
|||
// 查找用户
|
||||
user, err := model.GetUserByID(1)
|
||||
if err != nil {
|
||||
util.Log().Panic("初始管理员用户不存在, %s", err)
|
||||
util.Log().Panic("Initial admin user not exist: %s", err)
|
||||
}
|
||||
|
||||
// 生成密码
|
||||
|
@ -23,9 +23,9 @@ func (script ResetAdminPassword) Run(ctx context.Context) {
|
|||
// 更改为新密码
|
||||
user.SetPassword(password)
|
||||
if err := user.Update(map[string]interface{}{"password": user.Password}); err != nil {
|
||||
util.Log().Panic("密码更改失败, %s", err)
|
||||
util.Log().Panic("Failed to update password: %s", err)
|
||||
}
|
||||
|
||||
c := color.New(color.FgWhite).Add(color.BgBlack).Add(color.Bold)
|
||||
util.Log().Info("初始管理员密码已更改为:" + c.Sprint(password))
|
||||
util.Log().Info("Initial admin user password changed to:" + c.Sprint(password))
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ func (script UserStorageCalibration) Run(ctx context.Context) {
|
|||
model.DB.Model(&model.File{}).Where("user_id = ?", user.ID).Select("sum(size) as total").Scan(&total)
|
||||
// 更新用户的容量
|
||||
if user.Storage != total.Total {
|
||||
util.Log().Info("将用户 [%s] 的容量由 %d 校准为 %d", user.Email,
|
||||
util.Log().Info("Calibrate used storage for user %q, from %d to %d.", user.Email,
|
||||
user.Storage, total.Total)
|
||||
}
|
||||
model.DB.Model(&user).Update("storage", total.Total)
|
||||
|
|
Loading…
Add table
Reference in a new issue