forked from jriou/coller
feat: Add JSON logging format
Fixes #40. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
acfad88cb8
commit
2d8d7efbcb
3 changed files with 24 additions and 3 deletions
|
@ -41,6 +41,7 @@ func handleMain() int {
|
|||
quiet := flag.Bool("quiet", false, "Log errors only")
|
||||
verbose := flag.Bool("verbose", false, "Print more logs")
|
||||
debug := flag.Bool("debug", false, "Print even more logs")
|
||||
jsonFormat := flag.Bool("json", false, "Print logs in JSON format")
|
||||
encryptionKey := flag.String("encryption-key", os.Getenv("COLLER_ENCRYPTION_KEY"), "Key to decrypt the note")
|
||||
askEncryptionKey := flag.Bool("ask-encryption-key", false, "Read encryption key from input")
|
||||
fileName := flag.String("file", "", "Write content of the note to a file")
|
||||
|
@ -72,7 +73,13 @@ func handleMain() int {
|
|||
if *quiet {
|
||||
level = slog.LevelError
|
||||
}
|
||||
logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: level}))
|
||||
|
||||
var logger *slog.Logger
|
||||
if *jsonFormat {
|
||||
logger = slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: level}))
|
||||
} else {
|
||||
logger = slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: level}))
|
||||
}
|
||||
|
||||
if *askEncryptionKey {
|
||||
fmt.Print("Encryption key: ")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue