Updated log functions

This commit is contained in:
anoshenko 2022-11-09 13:40:08 +03:00
parent ecbcda7a53
commit ff5c73b7c3
4 changed files with 15 additions and 17 deletions

View File

@ -2,7 +2,6 @@ package rui
import (
"fmt"
"log"
"runtime"
)
@ -10,14 +9,8 @@ import (
// clients and the server is displayed in the debug log
var ProtocolInDebugLog = false
var debugLogFunc func(string) = func(text string) {
log.Println("\033[34m" + text)
}
var errorLogFunc = func(text string) {
log.Println("\033[31m" + text)
//println(text)
}
var debugLogFunc func(string) = debugLog
var errorLogFunc func(string) = errorLog
// SetDebugLog sets a function for outputting debug info.
// The default value is nil (debug info is ignored)

View File

@ -20,6 +20,14 @@ import (
//go:embed app_socket.js
var socketScripts string
func debugLog(text string) {
log.Println("\033[34m" + text)
}
func errorLog(text string) {
log.Println("\033[31m" + text)
}
type application struct {
server *http.Server
params AppParams

View File

@ -25,10 +25,14 @@ func (app *wasmApp) Finish() {
app.session.close()
}
func wasmLog(text string) {
func debugLog(text string) {
js.Global().Get("console").Call("log", text)
}
func errorLog(text string) {
js.Global().Get("console").Call("log", "%c"+text, "color: #F00;")
}
func (app *wasmApp) handleMessage(this js.Value, args []js.Value) any {
if len(args) > 0 {
text := args[0].String()
@ -160,9 +164,6 @@ func (app *wasmApp) init(params AppParams) {
// StartApp - create the new wasmApp and start it
func StartApp(addr string, createContentFunc func(Session) SessionContent, params AppParams) {
SetDebugLog(wasmLog)
SetErrorLog(wasmLog)
if createContentFunc == nil {
return
}

View File

@ -1,8 +1,4 @@
function log(s) {
console.log(s);
}
window.onfocus = function(event) {
windowFocus = true
sendMessage( "session-resume{session=" + sessionID +"}" );