forked from djosephsen/lazlo
/
config.go
33 lines (29 loc) · 831 Bytes
/
config.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 lib
import (
"github.com/ccding/go-logging/logging"
"github.com/danryan/env"
"os"
"time"
)
// Config struct
type Config struct {
Name string `env:"key=LAZLO_NAME default=lazlo"`
Token string `env:"key=LAZLO_TOKEN"`
URL string `env:"key=LAZLO_URL default=http://localhost"`
LogLevel string `env:"key=LAZLO_LOG_LEVEL default=info"`
RedisURL string `env:"key=LAZLO_REDIS_URL"`
RedisPW string `env:"key=LAZLO_REDIS_PW"`
Port string `env:"key=PORT"`
}
func newConfig() *Config {
c := &Config{}
env.MustProcess(c)
return c
}
func newLogger() *logging.Logger {
format := "%25s [%s] %8s: %s\n time,name,levelname,message"
timeFormat := time.RFC3339
level := logging.GetLevelValue(`INFO`)
logger, _ := logging.WriterLogger("lazlo", level, format, timeFormat, os.Stdout, true)
return logger
}