log

package
v3.0.0-...-2742eba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 5 Imported by: 0

README

log Plugin

This example plugin provides a way to generate hashes of strings.

Installation

Add the plugin to the Plugins option in the Applications options:

    Plugins: map[string]application.Plugin{
        "log": log.NewPlugin(),
    },

Usage

You can then call the methods from the frontend:

    wails.Plugin("log","All","hello world").then((result) => console.log(result))

This method returns a struct with the following fields:

    interface Hashes {
        MD5: string;
        SHA1: string;
        SHA256: string;
    }

A TypeScript definition file is provided for this interface.

Support

If you find a bug in this plugin, please raise a ticket here. Please do not contact the Wails team for support.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Where the logs are written to. Defaults to os.Stderr
	// If you want to write to a file, use os.OpenFile()
	// e.g. os.OpenFile("mylog.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	// Closes the writer when the app shuts down
	Writer io.WriteCloser

	// The initial log level. Defaults to Debug
	Level LogLevel

	// Disables the log level prefixes
	DisablePrefix bool

	// Handles errors that occur when writing to the log
	ErrorHandler func(err error)
}

type LogLevel

type LogLevel = float64
const (
	Trace LogLevel = iota + 1
	Debug
	Info
	Warning
	Error
	Fatal
)

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func NewPlugin

func NewPlugin() *Plugin

func NewPluginWithConfig

func NewPluginWithConfig(config *Config) *Plugin

func (*Plugin) CallableByJS

func (p *Plugin) CallableByJS() []string

CallableByJS returns a list of methods that can be called from the frontend

func (*Plugin) Debug

func (p *Plugin) Debug(message string, args ...any)

func (*Plugin) Error

func (p *Plugin) Error(message string, args ...any)

func (*Plugin) Fatal

func (p *Plugin) Fatal(message string, args ...any)

func (*Plugin) Info

func (p *Plugin) Info(message string, args ...any)

func (*Plugin) Init

func (p *Plugin) Init(app *application.App) error

func (*Plugin) InjectJS

func (p *Plugin) InjectJS() string

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns the name of the plugin. You should use the go module format e.g. github.com/myuser/myplugin

func (*Plugin) SetLevel

func (p *Plugin) SetLevel(newLevel LogLevel)

func (*Plugin) Shutdown

func (p *Plugin) Shutdown()

Shutdown is called when the app is shutting down You can use this to clean up any resources you have allocated

func (*Plugin) Trace

func (p *Plugin) Trace(message string, args ...any)

func (*Plugin) Warning

func (p *Plugin) Warning(message string, args ...any)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL