diff --git a/v2/test/kitchensink/frontend/src/components/CodeBlock.svelte b/v2/test/kitchensink/frontend/src/components/CodeBlock.svelte index 2935711c3..3eb4bd15d 100644 --- a/v2/test/kitchensink/frontend/src/components/CodeBlock.svelte +++ b/v2/test/kitchensink/frontend/src/components/CodeBlock.svelte @@ -20,11 +20,13 @@ $: code = isJs ? jsCode : goCode; // Handle hiding example - let showCode = true; + let showCode = false; function toggleExample() { showCode = !showCode; } + + export let id; // Handle hiding example let showRun = true; @@ -40,8 +42,8 @@ Go - - + + {#if description} diff --git a/v2/test/kitchensink/frontend/src/pages/logging/Log/Log.svelte b/v2/test/kitchensink/frontend/src/pages/logging/Log/Log.svelte new file mode 100644 index 000000000..6b84166af --- /dev/null +++ b/v2/test/kitchensink/frontend/src/pages/logging/Log/Log.svelte @@ -0,0 +1,62 @@ + + + +
+
+
+ + {#each loglevels as option, index} + {#if index === $logLevel} +
Current Log Level
+ {/if} +
+ + +
+ {/each} +
+ +
+ + +
+ + +
+
+
+ diff --git a/v2/test/kitchensink/frontend/src/pages/logging/code.go b/v2/test/kitchensink/frontend/src/pages/logging/Log/code.go similarity index 100% rename from v2/test/kitchensink/frontend/src/pages/logging/code.go rename to v2/test/kitchensink/frontend/src/pages/logging/Log/code.go diff --git a/v2/test/kitchensink/frontend/src/pages/logging/code.jsx b/v2/test/kitchensink/frontend/src/pages/logging/Log/code.jsx similarity index 100% rename from v2/test/kitchensink/frontend/src/pages/logging/code.jsx rename to v2/test/kitchensink/frontend/src/pages/logging/Log/code.jsx diff --git a/v2/test/kitchensink/frontend/src/pages/logging/Logging.svelte b/v2/test/kitchensink/frontend/src/pages/logging/Logging.svelte index 7241a11aa..2720ee16e 100644 --- a/v2/test/kitchensink/frontend/src/pages/logging/Logging.svelte +++ b/v2/test/kitchensink/frontend/src/pages/logging/Logging.svelte @@ -1,77 +1,36 @@

Logging

- Logging is part of the Wails Runtime and is accessed through the runtime.Log object. There are {options.length} methods available: + Logging is part of the Wails Runtime and is accessed through the runtime.Log object. There are {loglevels.length} methods available: - All methods will log to the console and Fatal will also exit the program. +
+ + The default logger will log all messages to the console EG:
+
+INFO  | I am an Info message
+ERROR | I am an Error message
+WARN  | I am a Warning message
+    
+ + Fatal will print the message and then immediately exit the program.
- -
-
- -
- - {#each options as option, index} - {#if index === $logLevel} -
Current Log Level
- {/if} -
- - -
- {/each} -
+ +
+ - -
- - -
- - -
-
-
diff --git a/v2/test/kitchensink/frontend/src/pages/logging/SetLogLevel/SetLogLevel.svelte b/v2/test/kitchensink/frontend/src/pages/logging/SetLogLevel/SetLogLevel.svelte new file mode 100644 index 000000000..912ea34b3 --- /dev/null +++ b/v2/test/kitchensink/frontend/src/pages/logging/SetLogLevel/SetLogLevel.svelte @@ -0,0 +1,32 @@ + + + +
+
+ +
+ + {#each options as option} +
+ + +
+ {/each} +
+
+
+
\ No newline at end of file diff --git a/v2/test/kitchensink/frontend/src/pages/logging/SetLogLevel/code.go b/v2/test/kitchensink/frontend/src/pages/logging/SetLogLevel/code.go new file mode 100644 index 000000000..08abc2cb1 --- /dev/null +++ b/v2/test/kitchensink/frontend/src/pages/logging/SetLogLevel/code.go @@ -0,0 +1,23 @@ +package main + +// SET LOG LEVEL + +import wails "github.com/wailsapp/wails/v2" + +type MyStruct struct { + runtime *wails.Runtime +} + +func (l *MyStruct) WailsInit(runtime *wails.Runtime) error { + + runtime.Log.Print(message) + runtime.Log.Trace(message) + runtime.Log.Debug(message) + runtime.Log.Info(message) + runtime.Log.Warning(message) + runtime.Log.Error(message) + runtime.Log.Fatal(message) + + l.runtime = runtime + return nil +} diff --git a/v2/test/kitchensink/frontend/src/pages/logging/SetLogLevel/code.jsx b/v2/test/kitchensink/frontend/src/pages/logging/SetLogLevel/code.jsx new file mode 100644 index 000000000..8e10ac834 --- /dev/null +++ b/v2/test/kitchensink/frontend/src/pages/logging/SetLogLevel/code.jsx @@ -0,0 +1,20 @@ +import { Log } from '@wails/runtime'; + + +// SET LOG LEVEL + +function doSomeOperation() { + // Do things + let value = doSomething(); + Log.Print("A raw message"); + Log.Trace("I got: " + value); + Log.Debug("A debug message"); + Log.Info("An Info message"); + Log.Warning("A Warning message"); + Log.Error("An Error message"); +} + +function abort() { + // Do some things + Log.Fatal("I accidentally the whole application!"); +} \ No newline at end of file