mirror of
https://github.com/1f349/lavender.git
synced 2024-12-22 07:34:06 +00:00
Add debug logging mode
This commit is contained in:
parent
447f6befbe
commit
8d489825d7
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/1f349/lavender/server"
|
"github.com/1f349/lavender/server"
|
||||||
"github.com/1f349/mjwt"
|
"github.com/1f349/mjwt"
|
||||||
"github.com/1f349/violet/utils"
|
"github.com/1f349/violet/utils"
|
||||||
|
"github.com/charmbracelet/log"
|
||||||
"github.com/golang-jwt/jwt/v4"
|
"github.com/golang-jwt/jwt/v4"
|
||||||
"github.com/google/subcommands"
|
"github.com/google/subcommands"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
@ -19,7 +20,10 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serveCmd struct{ configPath string }
|
type serveCmd struct {
|
||||||
|
configPath string
|
||||||
|
debugMode bool
|
||||||
|
}
|
||||||
|
|
||||||
func (s *serveCmd) Name() string { return "serve" }
|
func (s *serveCmd) Name() string { return "serve" }
|
||||||
|
|
||||||
@ -27,6 +31,7 @@ func (s *serveCmd) Synopsis() string { return "Serve API authentication service"
|
|||||||
|
|
||||||
func (s *serveCmd) SetFlags(f *flag.FlagSet) {
|
func (s *serveCmd) SetFlags(f *flag.FlagSet) {
|
||||||
f.StringVar(&s.configPath, "conf", "", "/path/to/config.json : path to the config file")
|
f.StringVar(&s.configPath, "conf", "", "/path/to/config.json : path to the config file")
|
||||||
|
f.BoolVar(&s.debugMode, "debug", false, "enable debug mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serveCmd) Usage() string {
|
func (s *serveCmd) Usage() string {
|
||||||
@ -38,6 +43,10 @@ func (s *serveCmd) Usage() string {
|
|||||||
func (s *serveCmd) Execute(_ context.Context, _ *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
|
func (s *serveCmd) Execute(_ context.Context, _ *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
|
||||||
logger.Logger.Info("Starting...")
|
logger.Logger.Info("Starting...")
|
||||||
|
|
||||||
|
if s.debugMode {
|
||||||
|
logger.Logger.SetLevel(log.DebugLevel)
|
||||||
|
}
|
||||||
|
|
||||||
if s.configPath == "" {
|
if s.configPath == "" {
|
||||||
logger.Logger.Fatal("Config flag is missing")
|
logger.Logger.Fatal("Config flag is missing")
|
||||||
return subcommands.ExitUsageError
|
return subcommands.ExitUsageError
|
||||||
|
Loading…
Reference in New Issue
Block a user