added server logging to file, added logging and formatting to info and lock commands
This commit is contained in:
@@ -2,12 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/deranjer/gvc/server/engine"
|
||||
serverconfig "github.com/deranjer/gvc/server/serverconfig"
|
||||
"github.com/deranjer/store"
|
||||
"github.com/labstack/echo"
|
||||
"github.com/labstack/gommon/log"
|
||||
"github.com/labstack/echo/middleware"
|
||||
)
|
||||
|
||||
var version = "0.1"
|
||||
@@ -22,6 +24,7 @@ func main() {
|
||||
fmt.Printf("Unable to find config file: %s\n", err)
|
||||
fmt.Println("Since no config found, creating a default config to use...")
|
||||
conf = serverconfig.GvcServerConfig{
|
||||
LogFile: "gvclog.log",
|
||||
Version: "0.1",
|
||||
Port: 80,
|
||||
RepoRootPath: "repos", //default repos directory will be cwd\repos
|
||||
@@ -43,9 +46,20 @@ func main() {
|
||||
// Setup a new server instance
|
||||
var server engine.GVCServer
|
||||
server.Config = conf
|
||||
log.Info("Logger starting...")
|
||||
fmt.Println("Attempting to start logger...")
|
||||
// Setting up the logger to file output
|
||||
logFile, err := os.OpenFile(conf.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("unable to open log file at: %s, exiting with error: %s", conf.LogFile, err)
|
||||
}
|
||||
defer logFile.Close()
|
||||
// Setup the web server
|
||||
e := echo.New()
|
||||
// Setup the logger to print to the file specified in config
|
||||
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
||||
Output: logFile,
|
||||
}))
|
||||
e.Logger.Info("echo logger has started")
|
||||
server.Echo = e
|
||||
//Start the routes
|
||||
//e.GET("/hello", server.Hello)
|
||||
|
Reference in New Issue
Block a user