diff --git a/src/core/connectordb.go b/src/core/connectordb.go index c9d3e679..261bde81 100755 --- a/src/core/connectordb.go +++ b/src/core/connectordb.go @@ -171,9 +171,8 @@ func startDatabase(dbPath string) error { if err == util.ErrAlreadyRunning && !*forceStart { fmt.Println("Use -force to force start the database even with connectordb.pid in there.") return err - } else { - return err } + return err } if err := dbmaker.Init(config.GetConfiguration()); err != nil { @@ -197,7 +196,7 @@ func stopDatabase(dbPath string) error { } if err := dbmaker.Stop(config.GetConfiguration()); err != nil { - log.Printf("%v", err.Error()) + log.Errorf("%v", err.Error()) } return nil diff --git a/src/plugins/webclient/streamweb.go b/src/plugins/webclient/streamweb.go index a62eb53c..279975b0 100755 --- a/src/plugins/webclient/streamweb.go +++ b/src/plugins/webclient/streamweb.go @@ -1,10 +1,11 @@ package webclient import ( - log "github.com/Sirupsen/logrus" "net/http" "strconv" + log "github.com/Sirupsen/logrus" + "github.com/gorilla/mux" ) @@ -47,7 +48,7 @@ func editStreamAction(se *SessionEnvironment) { err = se.Operator.UpdateStream(stream) if err != nil { - log.Printf(err.Error()) + log.Errorf(err.Error()) se.Session.AddFlash(err.Error()) } else { se.Session.AddFlash("Created Device") @@ -67,7 +68,7 @@ func createStreamAction(se *SessionEnvironment) { device, err := se.Operator.ReadDeviceByID(int64(devid)) if err != nil { - log.Printf(err.Error()) + log.Errorf(err.Error()) se.Session.AddFlash("Error getting device, maybe it was deleted?") goto redirect } @@ -75,7 +76,7 @@ func createStreamAction(se *SessionEnvironment) { err = se.Operator.CreateStreamByDeviceID(device.DeviceId, name, "x") if err != nil { - log.Printf(err.Error()) + log.Errorf(err.Error()) se.Session.AddFlash("Error creating stream.") } diff --git a/src/plugins/webclient/userweb.go b/src/plugins/webclient/userweb.go index d96b44d4..3f08dcd6 100755 --- a/src/plugins/webclient/userweb.go +++ b/src/plugins/webclient/userweb.go @@ -1,8 +1,9 @@ package webclient import ( - log "github.com/Sirupsen/logrus" "net/http" + + log "github.com/Sirupsen/logrus" ) func getUserPage(se *SessionEnvironment) { @@ -10,7 +11,7 @@ func getUserPage(se *SessionEnvironment) { pageData := make(map[string]interface{}) - log.Printf("userdb: %p, user: %v\n", userdb, se.User) + log.Debugf("userdb: %p, user: %v", userdb, se.User) devices, err := userdb.ReadAllDevicesByUserID(se.User.UserId) pageData["devices"] = devices diff --git a/src/plugins/webclient/web.go b/src/plugins/webclient/web.go index 625ec02c..5eb5c25a 100755 --- a/src/plugins/webclient/web.go +++ b/src/plugins/webclient/web.go @@ -3,12 +3,13 @@ package webclient import ( "encoding/gob" "html/template" - log "github.com/Sirupsen/logrus" "net/http" "path" "streamdb" "streamdb/users" + log "github.com/Sirupsen/logrus" + "github.com/gorilla/mux" "github.com/kardianos/osext" ) @@ -47,14 +48,14 @@ func authWrapper(h WebHandler) http.HandlerFunc { log.Printf("Doing login\n") se, err := NewSessionEnvironment(writer, request) - log.Printf("Created session\n") + log.Debugf("Created session\n") if err != nil || se.User == nil || se.Device == nil { - log.Printf("Error: %v, %v\n", err, se) + log.Errorf("Error: %v, %v\n", err, se) http.Redirect(writer, request, "/login/", http.StatusTemporaryRedirect) return } - log.Printf("Serving page\n") + log.Debugf("Serving page\n") h(&se) }) @@ -63,10 +64,10 @@ func authWrapper(h WebHandler) http.HandlerFunc { // Display the login page func getLogin(writer http.ResponseWriter, request *http.Request) { - log.Printf("Showing login page\n") + log.Printf("Showing login page") se, err := NewSessionEnvironment(writer, request) - log.Printf("got session\n") + log.Debugf("got session") // Don't log in somebody that's already logged in if err == nil && se.User != nil && se.Device != nil { @@ -84,7 +85,7 @@ func getLogin(writer http.ResponseWriter, request *http.Request) { // Display the login page func getLogout(writer http.ResponseWriter, request *http.Request) { - log.Printf("logout\n") + log.Printf("logout") se, _ := NewSessionEnvironment(writer, request) se.Logoff() @@ -98,7 +99,7 @@ func postLogin(writer http.ResponseWriter, request *http.Request) { userstr := request.PostFormValue("username") passstr := request.PostFormValue("password") - log.Printf("Log in attempt: %v\n", userstr) + log.Printf("Log in attempt: %v", userstr) usroperator, err := userdb.LoginOperator(userstr, passstr) if err != nil { @@ -126,28 +127,28 @@ func postLogin(writer http.ResponseWriter, request *http.Request) { func init() { folderPath, _ := osext.ExecutableFolder() templatesPath := path.Join(folderPath, "templates") - basePath := path.Join(templatesPath, "base.html") + basePath := path.Join(templatesPath, "base.html") // Parses our templates relative to the template path including the base // everything needs tMust := func(templateName string) *template.Template { tPath := path.Join(templatesPath, templateName) - return template.Must(template.ParseFiles(tPath, basePath)) - }; - - userEditTemplate = tMust("user_edit.html") - loginHomeTemplate = tMust("root.html") - deviceInfoTemplate = tMust("device_info.html") - firstrunTemplate = tMust("firstrun.html") - addUserTemplate = tMust("newuser.html") - loginPageTemplate = tMust("login.html") + return template.Must(template.ParseFiles(tPath, basePath)) + } + + userEditTemplate = tMust("user_edit.html") + loginHomeTemplate = tMust("root.html") + deviceInfoTemplate = tMust("device_info.html") + firstrunTemplate = tMust("firstrun.html") + addUserTemplate = tMust("newuser.html") + loginPageTemplate = tMust("login.html") } func Setup(subroutePrefix *mux.Router, udb *streamdb.Database) { userdb = udb folderPath, _ := osext.ExecutableFolder() includepath := path.Join(folderPath, "static") - log.Printf("Include path set to: %v", includepath) + log.Debugf("Include path set to: %v", includepath) subroutePrefix.PathPrefix("/inc/").Handler(http.StripPrefix("/inc/", http.FileServer(http.Dir(includepath)))) subroutePrefix.HandleFunc("/login/", http.HandlerFunc(getLogin)) diff --git a/src/streamdb/dbmaker/gnatsd.go b/src/streamdb/dbmaker/gnatsd.go index c63671f4..a3fedbd4 100755 --- a/src/streamdb/dbmaker/gnatsd.go +++ b/src/streamdb/dbmaker/gnatsd.go @@ -65,7 +65,7 @@ func (srv *GnatsdService) Start() error { return nil } if srv.Stat != StatusInit { - log.Printf("Could not start gnatsd, status is %v", srv.Stat) + log.Errorf("Could not start gnatsd, status is %v", srv.Stat) return ErrNotInitialized } diff --git a/src/streamdb/dbmaker/postgres.go b/src/streamdb/dbmaker/postgres.go index 9985ae08..b893bf5c 100755 --- a/src/streamdb/dbmaker/postgres.go +++ b/src/streamdb/dbmaker/postgres.go @@ -106,7 +106,7 @@ func (srv *PostgresService) Start() error { return nil } if srv.Stat != StatusInit { - log.Printf("Could not start postgres, status is %v", srv.Stat) + log.Errorf("Could not start postgres, status is %v", srv.Stat) return ErrNotInitialized } srv.Stat = StatusRunning diff --git a/src/streamdb/dbmaker/redis.go b/src/streamdb/dbmaker/redis.go index eefc42da..02d9385d 100755 --- a/src/streamdb/dbmaker/redis.go +++ b/src/streamdb/dbmaker/redis.go @@ -63,7 +63,7 @@ func (srv *RedisService) Start() error { return nil } if srv.Stat != StatusInit { - log.Printf("Could not start redis, status is %v", srv.Stat) + log.Errorf("Could not start redis, status is %v", srv.Stat) return ErrNotInitialized }