Support Trace in kitchensink

This commit is contained in:
Lea Anthony 2020-10-09 14:36:15 +11:00
commit b5c8dfac97
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
7 changed files with 21 additions and 17 deletions

View file

@ -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)

View file

@ -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": {

View file

@ -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",

View file

@ -1,5 +1,5 @@
import { writable } from 'svelte/store';
import runtime from '@wailsapp/runtime2';
import runtime from '@wails/runtime';
export let selectedPage = writable();

View file

@ -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.

View file

@ -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");

View file

@ -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)