Skip to content
Snippets Groups Projects
Commit 6db70285 authored by Jono Wenger's avatar Jono Wenger
Browse files

Add logging control to workers

parent 68b02415
Branches
Tags
2 merge requests!67fix for latest client release,!52XX-4382 / Move indexedDb databases to web workers
......@@ -11,6 +11,7 @@ const go = new Go();
const binPath = 'xxdk-channelsIndexedDkWorker.wasm'
WebAssembly.instantiateStreaming(fetch(binPath), go.importObject).then((result) => {
go.run(result.instance);
LogLevel(2);
}).catch((err) => {
console.error(err);
});
\ No newline at end of file
......@@ -13,13 +13,25 @@ import (
"fmt"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/xxdk-wasm/indexedDb"
"gitlab.com/elixxir/xxdk-wasm/wasm"
"syscall/js"
)
func init() {
// Set up Javascript console listener set at level INFO
ll := wasm.NewJsConsoleLogListener(jww.LevelInfo)
jww.SetLogListeners(ll.Listen)
jww.SetStdoutThreshold(jww.LevelFatal + 1)
}
func main() {
fmt.Println("[WW] Starting xxDK WebAssembly Channels Database Worker.")
jww.SetStdoutThreshold(jww.LevelDebug)
jww.INFO.Print("[WW] Starting xxDK WebAssembly Channels Database Worker.")
js.Global().Set("LogLevel", js.FuncOf(wasm.LogLevel))
js.Global().Set("LogToFile", js.FuncOf(wasm.LogToFile))
js.Global().Set("RegisterLogWriter", js.FuncOf(wasm.RegisterLogWriter))
m := &manager{mh: indexedDb.NewMessageHandler("ChannelsIndexedDbWorker")}
m.RegisterHandlers()
m.mh.SignalReady()
......
......@@ -11,6 +11,7 @@ const go = new Go();
const binPath = 'xxdk-dmIndexedDkWorker.wasm'
WebAssembly.instantiateStreaming(fetch(binPath), go.importObject).then((result) => {
go.run(result.instance);
LogLevel(2);
}).catch((err) => {
console.error(err);
});
\ No newline at end of file
......@@ -13,13 +13,25 @@ import (
"fmt"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/xxdk-wasm/indexedDb"
"gitlab.com/elixxir/xxdk-wasm/wasm"
"syscall/js"
)
func init() {
// Set up Javascript console listener set at level INFO
ll := wasm.NewJsConsoleLogListener(jww.LevelInfo)
jww.SetLogListeners(ll.Listen)
jww.SetStdoutThreshold(jww.LevelFatal + 1)
}
func main() {
fmt.Println("[WW] Starting xxDK WebAssembly DM Database Worker.")
jww.SetStdoutThreshold(jww.LevelDebug)
jww.INFO.Print("[WW] Starting xxDK WebAssembly DM Database Worker.")
js.Global().Set("LogLevel", js.FuncOf(wasm.LogLevel))
js.Global().Set("LogToFile", js.FuncOf(wasm.LogToFile))
js.Global().Set("RegisterLogWriter", js.FuncOf(wasm.RegisterLogWriter))
m := &manager{mh: indexedDb.NewMessageHandler("DmIndexedDbWorker")}
m.RegisterHandlers()
m.mh.SignalReady()
......
......@@ -22,6 +22,9 @@ import (
// TODO:
// 1. Fix ID counter
// 2. Use transfer list when sending
// 3. Get path to JS file from bindings
// 4. restructure packages
// 5. fix tag system
// InitID is the ID for the first item in the handler list. If the list only
// contains one handler, then this is the ID of that handler. If the list has
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment