mirror of
https://github.com/go-gitea/gitea
synced 2024-11-01 15:54:25 +00:00
35f37a3625
One of the repeatedly reported issues has been that gitea produces too much console logging during set up even if the console logger is turned off. Fundamentally this is due to some otherwise very helpful logging that has to occur before logging is set up. This has come to a head with the merging of #16243 where otherwise potentially helpful Trace logging in the git module now appears on the console. This PR proposes three things: 1. Change the initial default logger to Info not Trace. 2. Change the logging for the AppPath things to Info in recompense. 3. Add two new command line options to gitea web: --quiet and --verbose `gitea web -q` or `gitea web --quiet` will only log Fatal level initially. `gitea web -verbose` will log at Trace. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"code.gitea.io/gitea/models"
|
|
"code.gitea.io/gitea/modules/log"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
// CmdConvert represents the available convert sub-command.
|
|
var CmdConvert = cli.Command{
|
|
Name: "convert",
|
|
Usage: "Convert the database",
|
|
Description: "A command to convert an existing MySQL database from utf8 to utf8mb4",
|
|
Action: runConvert,
|
|
}
|
|
|
|
func runConvert(ctx *cli.Context) error {
|
|
if err := initDB(); err != nil {
|
|
return err
|
|
}
|
|
|
|
log.Info("AppPath: %s", setting.AppPath)
|
|
log.Info("AppWorkPath: %s", setting.AppWorkPath)
|
|
log.Info("Custom path: %s", setting.CustomPath)
|
|
log.Info("Log path: %s", setting.LogRootPath)
|
|
setting.InitDBConfig()
|
|
|
|
if !setting.Database.UseMySQL {
|
|
fmt.Println("This command can only be used with a MySQL database")
|
|
return nil
|
|
}
|
|
|
|
if err := models.ConvertUtf8ToUtf8mb4(); err != nil {
|
|
log.Fatal("Failed to convert database from utf8 to utf8mb4: %v", err)
|
|
return err
|
|
}
|
|
|
|
fmt.Println("Converted successfully, please confirm your database's character set is now utf8mb4")
|
|
|
|
return nil
|
|
}
|