commit aee1e0740e33b301c6d860d6cf2a105633b34967
parent 52431a62042365a5ea65bd7484f5e56d20cc5d31
Author: MTRNord <mtrnord1@gmail.com>
Date: Mon, 21 Aug 2017 21:35:13 +0200
Fix Logger Partially and fix Login
Diffstat:
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/main.go b/main.go
@@ -12,7 +12,8 @@ var localLog *log.Logger
func main() {
localLog = util.Logger()
- util.StartFileLog(localLog)
+ localLog = util.StartFileLog(localLog)
+ localLog.Println("Starting Neo")
widgets.NewQApplication(len(os.Args), os.Args)
@@ -30,4 +31,5 @@ func main() {
//enter the main event loop
widgets.QApplication_Exec()
+ localLog.Println("Finished Startup Neo")
}
diff --git a/matrix/login.go b/matrix/login.go
@@ -26,7 +26,7 @@ func getClient(homeserverURL, userID, accessToken string) (*gomatrix.Client, err
func LoginUser(username, password string) (*gomatrix.Client, error) {
usernameSplit := strings.Split(username, ":")
homeserverURL := usernameSplit[1]
- cli, cliErr := getClient(homeserverURL, "", "")
+ cli, cliErr := getClient("https://"+homeserverURL, "", "")
if cliErr != nil {
return nil, cliErr
}
diff --git a/uis.go b/uis.go
@@ -1,23 +1,16 @@
package main
import (
- "log"
-
"github.com/Nordgedanken/Neo/matrix"
- "github.com/Nordgedanken/Neo/util"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/uitools"
"github.com/therecipe/qt/widgets"
)
-var localLog *log.Logger
-
//NewLoginUI initializes the login Screen
func NewLoginUI(windowWidth, windowHeight int) *widgets.QWidget {
var username string
var password string
- localLog = util.Logger()
- util.StartFileLog(localLog)
widget := widgets.NewQWidget(nil, 0)
diff --git a/util/logger.go b/util/logger.go
@@ -1,6 +1,7 @@
package util
import (
+ "io"
"log"
"os"
"sync"
@@ -19,16 +20,19 @@ func Logger() *log.Logger {
}
//StartFileLog initialises the logging function
-func StartFileLog(localLog *log.Logger) {
+func StartFileLog(localLog *log.Logger) *log.Logger {
if _, err := os.Stat("./log/"); os.IsNotExist(err) {
os.Mkdir("./log/", 0666)
}
f, err := os.OpenFile("./log/Main.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
- log.Fatalf("error opening file: %v", err)
+ localLog.Fatalf("error opening file: %v", err)
}
defer f.Close()
- localLog.SetOutput(f)
+ mw := io.MultiWriter(os.Stdout, f)
+
+ localLog.SetOutput(mw)
localLog.SetPrefix(time.Now().Format("2006-01-02 15:04:05"))
+ return localLog
}