mirror of https://github.com/anoshenko/rui.git
				
				
				
			Updated log functions
This commit is contained in:
		
							parent
							
								
									ecbcda7a53
								
							
						
					
					
						commit
						ff5c73b7c3
					
				
							
								
								
									
										11
									
								
								appLog.go
								
								
								
								
							
							
						
						
									
										11
									
								
								appLog.go
								
								
								
								
							| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,4 @@
 | 
			
		|||
 | 
			
		||||
function log(s) {
 | 
			
		||||
	console.log(s);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
window.onfocus = function(event) {
 | 
			
		||||
	windowFocus = true
 | 
			
		||||
	sendMessage( "session-resume{session=" + sessionID +"}" );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue