github.com/minio/mc@v0.0.0-20240503112107-b471de8d1882/cmd/admin-console.go (about) 1 // Copyright (c) 2015-2022 MinIO, Inc. 2 // 3 // This file is part of MinIO Object Storage stack 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package cmd 19 20 import ( 21 "fmt" 22 "strings" 23 24 "github.com/minio/cli" 25 ) 26 27 var adminConsoleFlags = []cli.Flag{ 28 cli.IntFlag{ 29 Name: "limit, l", 30 Usage: "show last n log entries", 31 Value: 10, 32 }, 33 cli.StringFlag{ 34 Name: "type, t", 35 Usage: "list error logs by type. Valid options are '[minio, application, all]'", 36 Value: "all", 37 }, 38 } 39 40 var adminConsoleCmd = cli.Command{ 41 Name: "console", 42 Usage: "show MinIO logs", 43 Action: mainAdminConsole, 44 OnUsageError: onUsageError, 45 Before: setGlobalsFromContext, 46 Flags: append(adminConsoleFlags, globalFlags...), 47 Hidden: true, 48 HideHelpCommand: true, 49 CustomHelpTemplate: "This command is not supported now and replaced by 'admin logs' command. Please use 'mc admin logs'.\n", 50 } 51 52 // mainAdminConsole - the entry function of console command 53 func mainAdminConsole(ctx *cli.Context) error { 54 newCmd := []string{"mc admin logs"} 55 56 var flgStr string 57 58 if ctx.IsSet("limit") { 59 flgStr = fmt.Sprintf("%s %d", "--last", ctx.Int("limit")) 60 newCmd = append(newCmd, flgStr) 61 } 62 63 if ctx.IsSet("type") { 64 flgStr = fmt.Sprintf("%s %s", "--type", strings.ToLower(ctx.String("type"))) 65 newCmd = append(newCmd, flgStr) 66 } 67 newCmd = append(newCmd, ctx.Args()...) 68 69 deprecatedError(strings.Join(newCmd, " ")) 70 return nil 71 }