-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
33 lines (26 loc) · 779 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"database/sql"
"github.com/lukecarr/tiny-todo/cmd"
"github.com/lukecarr/x/osx"
"github.com/mattn/go-colorable"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"modernc.org/sqlite"
)
func main() {
sql.Register("sqlite3", &sqlite.Driver{})
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
stdout := colorable.NewColorableStdout()
log.Logger = log.Output(zerolog.ConsoleWriter{Out: stdout})
logLevelEnv := osx.Getenv("LOG_LEVEL", "info")
logLevel, err := zerolog.ParseLevel(logLevelEnv)
if err != nil {
log.Fatal().
Str("Expected", "One of: panic, fatal, error, warn, info, debug, or trace").
Str("Got", logLevelEnv).
Msg("Please specify a valid logging level!")
}
log.Logger = log.Logger.Level(logLevel)
cmd.Execute()
}