logging

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

View Source
const (
	NewLogFileTag worker.Tag = "NewLogFile"
	WriteLogTag   worker.Tag = "WriteLog"
	GetFileTag    worker.Tag = "GetFile"
	GetFileExtTag worker.Tag = "GetFileExt"
	MaxSizeTag    worker.Tag = "MaxSize"
	SizeTag       worker.Tag = "Size"
)

List of tags that can be used when sending a message or registering a handler to receive a message.

Variables

This section is empty.

Functions

func EnableLogging added in v0.3.4

func EnableLogging(logLevel, fileLogLevel jww.Threshold, maxLogFileSizeMB int,
	workerScriptURL, workerName string) error

EnableLogging enables logging to the Javascript console and to a local or worker file buffer. This must be called only once at initialisation.

func EnableThreadLogging added in v0.3.4

func EnableThreadLogging(logLevel, fileLogLevel jww.Threshold,
	maxLogFileSizeMB int, workerName string, messagePort js.Value) error

EnableThreadLogging enables logging to the Javascript console and to a local or remote thread file buffer. This must be called only once at initialisation.

func GetLoggerJS

func GetLoggerJS(js.Value, []js.Value) any

GetLoggerJS returns the Logger object, used to manager where logging is recorded and accessing the log file.

Returns:

  • A Javascript representation of the Logger object.

Types

type Console

type Console struct {
	js.Value
	// contains filtered or unexported fields
}

Console contains the Javascript console object, which provides access to the browser's debugging console. This structure is defined for only a single method on the console object. For example, if the method is set to debug, then all calls to console.Write will print a debug message to the Javascript console.

Doc: https://developer.mozilla.org/en-US/docs/Web/API/console

func (*Console) Write

func (c *Console) Write(p []byte) (n int, err error)

Write writes the data to the Javascript console with preset method. Returns the number of bytes written.

type JsConsoleLogListener

type JsConsoleLogListener struct {
	jww.Threshold
	js.Value
	// contains filtered or unexported fields
}

JsConsoleLogListener redirects log output to the Javascript console using the correct console method.

func NewJsConsoleLogListener

func NewJsConsoleLogListener(threshold jww.Threshold) *JsConsoleLogListener

NewJsConsoleLogListener initialises a new log listener that listener for the specific threshold and prints the logs to the Javascript console.

func (*JsConsoleLogListener) Listen

func (ll *JsConsoleLogListener) Listen(t jww.Threshold) io.Writer

Listen is called for every logging event. This function adheres to the [jwalterweatherman.LogListener] type.

type Logger

type Logger interface {
	// StopLogging stops log message writes. Once logging is stopped, it cannot
	// be resumed and the log file cannot be recovered.
	StopLogging()

	// GetFile returns the entire log file.
	GetFile() []byte

	// Threshold returns the log level threshold used in the file.
	Threshold() jww.Threshold

	// MaxSize returns the maximum size, in bytes, of the log file before it
	// rolls over and starts overwriting the oldest entries
	MaxSize() int

	// Size returns the number of bytes written to the log file.
	Size() int

	// Worker returns the manager for the Javascript Worker object. If the
	// worker has not been initialized, it returns nil.
	Worker() *worker.Manager
}

Logger controls and accesses the log file for this binary.

func GetLogger

func GetLogger() Logger

GetLogger returns the Logger object, used to manager where logging is recorded.

type LoggerJS added in v0.3.4

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

LoggerJS is the Javascript wrapper for the Logger.

func (*LoggerJS) GetFile added in v0.3.4

func (l *LoggerJS) GetFile(js.Value, []js.Value) any

GetFile returns the entire log file.

If the log file is listening locally, it returns it from the local buffer. If it is listening from the worker, it blocks until the file is returned.

Returns a promise:

  • Resolves to the log file contents (string).

func (*LoggerJS) MaxSize added in v0.3.4

func (l *LoggerJS) MaxSize(js.Value, []js.Value) any

MaxSize returns the max size, in bytes, that the log file is allowed to be.

Returns:

  • Max file size (int).

func (*LoggerJS) Size added in v0.3.4

func (l *LoggerJS) Size(js.Value, []js.Value) any

Size returns the current size, in bytes, written to the log file.

If the log file is listening locally, it returns it from the local buffer. If it is listening from the worker, it blocks until the size is returned.

Returns a promise:

  • Resolves to the current file size (int).

func (*LoggerJS) StopLogging added in v0.3.4

func (l *LoggerJS) StopLogging(js.Value, []js.Value) any

StopLogging stops the logging of log messages and disables the log listener. If the log worker is running, it is terminated. Once logging is stopped, it cannot be resumed the log file cannot be recovered.

func (*LoggerJS) Threshold added in v0.3.4

func (l *LoggerJS) Threshold(js.Value, []js.Value) any

Threshold returns the log level threshold used in the file.

Returns:

  • Log level (int).

func (*LoggerJS) Worker added in v0.3.4

func (l *LoggerJS) Worker(js.Value, []js.Value) any

Worker returns the web worker object.

Returns:

  • Javascript worker object. If the worker has not been initialized, it returns null.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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