logging

package module
v0.0.0-...-0b6fd76 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

README

wasmCloud Logging Actor Interface

This actor provides an abstraction over the wasmcloud:logging contract. This allows actors to use normal logging notation (like info, warn, error, etc) to write logs from within the actor.

package main

import (
	core "github.com/wasmcloud/actor-interfaces/actor-core/go"
	log "github.com/wasmcloud/actor-interfaces/logging/go"
)

var logger *log.Host

func main() {
	logger = log.NewHost("default")

	core.Handlers{
		HealthRequest: healthRequest,
	}.Register()

	log.Handlers{
		WriteLog: writeLog,
	}.Register()

}

func healthRequest(request core.HealthCheckRequest) (core.HealthCheckResponse, error) {
	return core.HealthCheckResponse{
		Healthy: true,
	}, nil
}

func writeLog(target string, level string, text string) error {
	logger.WriteLog(target, level, text)
	return nil
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Host

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

func NewHost

func NewHost(binding string) *Host

func (*Host) WriteLog

func (h *Host) WriteLog(target string, level string, text string) error

Writes a log message to specified target and level. `target` is used to filter logs to a specific target, e.g. for logging to your specific actor name, and can be left as an empty string. `level` can be one of the following log levels: `error`, `warn`, `info`, `debug`, `trace`. It is up to the provider to ensure the `level` value is valid.

type WriteLogArgs

type WriteLogArgs struct {
	Target string
	Level  string
	Text   string
}

func DecodeWriteLogArgs

func DecodeWriteLogArgs(decoder *msgpack.Decoder) (WriteLogArgs, error)

func DecodeWriteLogArgsNullable

func DecodeWriteLogArgsNullable(decoder *msgpack.Decoder) (*WriteLogArgs, error)

func (*WriteLogArgs) Decode

func (o *WriteLogArgs) Decode(decoder *msgpack.Decoder) error

func (*WriteLogArgs) Encode

func (o *WriteLogArgs) Encode(encoder msgpack.Writer) error

Jump to

Keyboard shortcuts

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