adding logging to server
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/deranjer/store"
|
||||
"github.com/labstack/echo"
|
||||
"github.com/labstack/echo/middleware"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
var version = "0.1"
|
||||
@@ -26,6 +27,7 @@ func main() {
|
||||
fmt.Println("Since no config found, creating a default config to use...")
|
||||
conf = serverconfig.GvcServerConfig{
|
||||
LogFile: "gvclog.log",
|
||||
LogLevel: 2,
|
||||
Version: "0.1",
|
||||
Port: 80,
|
||||
RepoRootPath: "repos", //default repos directory will be cwd\repos
|
||||
@@ -55,8 +57,15 @@ func main() {
|
||||
log.Fatalf("unable to open log file at: %s, exiting with error: %s", conf.LogFile, err)
|
||||
}
|
||||
defer logFile.Close()
|
||||
// Setup non-http logging (using middleware for Echo http logging)
|
||||
logLevel, err := serverconfig.SetLogLevel(conf.LogLevel)
|
||||
if err != nil {
|
||||
fmt.Println("invalid log level set in config, setting to info")
|
||||
}
|
||||
serverlog := zerolog.New(logFile)
|
||||
serverlog.WithLevel(logLevel)
|
||||
// Check/Setup the database
|
||||
database.NewDB(conf.DatabaseLocation)
|
||||
database.NewDB(conf.DatabaseLocation, &serverlog)
|
||||
// Setup the web server
|
||||
e := echo.New()
|
||||
// Setup the logger to print to the file specified in config
|
||||
|
Reference in New Issue
Block a user