Add debug level command
This commit is contained in:
22
commands.go
22
commands.go
@ -8,6 +8,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rudi9719/loggy"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupCommands() {
|
func setupCommands() {
|
||||||
@ -69,6 +71,15 @@ func setupCommands() {
|
|||||||
Exec: Commands,
|
Exec: Commands,
|
||||||
}
|
}
|
||||||
commands = append(commands, listCommands)
|
commands = append(commands, listCommands)
|
||||||
|
|
||||||
|
debugLevel := Command{
|
||||||
|
Name: "Debug Level",
|
||||||
|
RequiresAdmin: true,
|
||||||
|
Keywords: []string{"debug"},
|
||||||
|
Exec: Debug,
|
||||||
|
Help: "Set the log level for loggy",
|
||||||
|
}
|
||||||
|
commands = append(commands, debugLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Commands(b BotCommand) bool {
|
func Commands(b BotCommand) bool {
|
||||||
@ -87,6 +98,17 @@ func Commands(b BotCommand) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Debug(b BotCommand) bool {
|
||||||
|
defer log.PanicSafe()
|
||||||
|
level, err := strconv.Atoi(b.Parts[0])
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
config.LogOpts.Level = loggy.LogLevel(level)
|
||||||
|
log = loggy.NewLogger(config.LogOpts)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func Reboot(b BotCommand) bool {
|
func Reboot(b BotCommand) bool {
|
||||||
defer log.PanicSafe()
|
defer log.PanicSafe()
|
||||||
if strings.Contains(b.Message.Content, rebootToken) {
|
if strings.Contains(b.Message.Content, rebootToken) {
|
||||||
|
|||||||
Reference in New Issue
Block a user