mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
Support Trace in kitchensink
This commit is contained in:
parent
ee01b7759e
commit
b5c8dfac97
7 changed files with 21 additions and 17 deletions
|
|
@ -43,7 +43,7 @@ func CreateApp(options *options.App) *App {
|
|||
|
||||
// Set up logger
|
||||
myLogger := logger.New(options.Logger)
|
||||
myLogger.SetLogLevel(logger.TRACE)
|
||||
myLogger.SetLogLevel(uint8(options.LogLevel))
|
||||
|
||||
window := ffenestri.NewApplicationWithConfig(options, myLogger)
|
||||
|
||||
|
|
|
|||
8
v2/test/kitchensink/frontend/package-lock.json
generated
8
v2/test/kitchensink/frontend/package-lock.json
generated
|
|
@ -123,10 +123,10 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@wailsapp/runtime2": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@wailsapp/runtime2/-/runtime2-1.0.3.tgz",
|
||||
"integrity": "sha512-DUE0WETfWeF5UhZ7vVcHQcHQf4SOk6FcXxEZkE9p4PJAtDp3+xLcC5nrm51h80W30sAFfc9Q5ukpfvP7k369wQ==",
|
||||
"@wails/runtime": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@wails/runtime/-/runtime-1.0.0.tgz",
|
||||
"integrity": "sha512-YKL9k4ZRvltnN9Io4gM03u7bk7VX9YjDLu8BdkaHws+3Tt0H+NKt/XnMTo9beUZdPDYnQOgAo5CTxR5UP+n/xA==",
|
||||
"dev": true
|
||||
},
|
||||
"alphanum-sort": {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^11.0.0",
|
||||
"@rollup/plugin-node-resolve": "^7.0.0",
|
||||
"@wailsapp/runtime2": "^1.0.3",
|
||||
"@wails/runtime": "^1.0.0",
|
||||
"focus-visible": "^5.0.2",
|
||||
"halfmoon": "^1.1.0",
|
||||
"postcss": "^8.1.1",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { writable } from 'svelte/store';
|
||||
import runtime from '@wailsapp/runtime2';
|
||||
import runtime from '@wails/runtime';
|
||||
|
||||
export let selectedPage = writable();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
<script>
|
||||
|
||||
import { Log } from '@wailsapp/runtime2';
|
||||
import { Log } from '@wails/runtime';
|
||||
import CodeBlock from '../../components/CodeBlock.svelte';
|
||||
import jsCode from './code.jsx';
|
||||
import goCode from './code.go';
|
||||
|
||||
var loglevel = 'Debug';
|
||||
var loglevel = 'Trace';
|
||||
var message = '';
|
||||
var isJs = false;
|
||||
|
||||
var options = ["Debug", "Info", "Warning", "Error", "Fatal"];
|
||||
var options = ["Trace", "Debug", "Info", "Warning", "Error", "Fatal"];
|
||||
|
||||
$: lang = isJs ? 'Javascript' : 'Go';
|
||||
|
||||
|
|
@ -32,11 +32,9 @@
|
|||
Logging is part of the Wails Runtime and is accessed through the <code>runtime.Log</code> object. There are 5 methods available:
|
||||
|
||||
<ul class="list">
|
||||
<li>Debug</li>
|
||||
<li>Info</li>
|
||||
<li>Warning</li>
|
||||
<li>Error</li>
|
||||
<li>Fatal</li>
|
||||
{#each options as option}
|
||||
<li>{options}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
All methods will log to the console and <code>Fatal</code> will also exit the program.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { Log } from '@wailsapp/runtime2';
|
||||
import { Log } from '@wails/runtime';
|
||||
|
||||
function doSomeOperation() {
|
||||
// Do things
|
||||
let value = doSomething();
|
||||
Log.Debug("I got: " + value);
|
||||
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");
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ func (l *Logger) WailsInit(runtime *wails.Runtime) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Trace will log the given message
|
||||
func (l *Logger) Trace(message string) {
|
||||
l.runtime.Log.Trace(message)
|
||||
}
|
||||
|
||||
// Debug will log the given message
|
||||
func (l *Logger) Debug(message string) {
|
||||
l.runtime.Log.Debug(message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue