logging

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package logging is part of the Tarmac suite of Host Callback packages. This package provides users with the ability to provide WASM functions with a host callback interface that provides logging capabilities.

import (
	"github.com/madflojo/tarmac/pkg/callbacks"
	"github.com/madflojo/tarmac/pkg/callbacks/logging"
)

func main() {
	// Create instance of logger to register for callback execution
	logger := logging.New(logging.Config{
		Log: MyCustomLogger,
	})

	// Create Callback router and register logger
	router := callbacks.New()
	router.RegisterCallback("logging", "Info", logger.Info)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Log is an interface that can be provided by the instantiator. This interface allows users to specify their logging
	// functionality or incorporate an existing logger into the Tarmac Host Callback function.
	Log Log
}

Config is provided to users to configure the Host Callback. All Tarmac Callbacks follow the same configuration format; each Config struct gives the specific Host Callback unique functionality.

type Log

type Log interface {
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Debug(args ...interface{})
	Trace(args ...interface{})
}

Log is an interface that can be provided and satisfied by the instantiator of the Logger struct. This interface allows users to specify their logging functionality or incorporate an existing logger into the Tarmac Host Callback functions.

type Logger

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

Logger provides a Host Callback interface to interact with the underlying logging system. WASM functions can call this callback interface which will coordinate and execute the host-supplied logger instance.

func New

func New(cfg Config) (*Logger, error)

New will create and return a new logger instance that users can register as a Tarmac Host Callback function. Users can provide a custom logger using the Configuration options supplied. By default, if there is no custom logger provided, the NoOpLog will be used.

func (*Logger) Debug

func (l *Logger) Debug(b []byte) ([]byte, error)

Debug will take the incoming byte slice data and call the internal logger converting the data to a string.

func (*Logger) Error

func (l *Logger) Error(b []byte) ([]byte, error)

Error will take the incoming byte slice data and call the internal logger converting the data to a string.

func (*Logger) Info

func (l *Logger) Info(b []byte) ([]byte, error)

Info will take the incoming byte slice data and call the internal logger converting the data to a string.

func (*Logger) Trace

func (l *Logger) Trace(b []byte) ([]byte, error)

Trace will take the incoming byte slice data and call the internal logger converting the data to a string.

func (*Logger) Warn

func (l *Logger) Warn(b []byte) ([]byte, error)

Warn will take the incoming byte slice data and call the internal logger converting the data to a string.

type NoOpLog

type NoOpLog struct{}

NoOpLog is a convience logger which is used as a default when users do not provide their own interface.

func (NoOpLog) Debug

func (log NoOpLog) Debug(args ...interface{})

Debug does nothing

func (NoOpLog) Error

func (log NoOpLog) Error(args ...interface{})

Error does nothing

func (NoOpLog) Info

func (log NoOpLog) Info(args ...interface{})

Info does nothing

func (NoOpLog) Trace

func (log NoOpLog) Trace(args ...interface{})

Trace does nothing

func (NoOpLog) Warn

func (log NoOpLog) Warn(args ...interface{})

Warn does nothing

Jump to

Keyboard shortcuts

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