accesslog

package
v0.0.0-...-d72b2cd Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: BSD-3-Clause Imports: 5 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEgressOperators

func CreateEgressOperators(read func() ([]byte, error)) error

CreateEgressOperators - provides creation of egress operators

func CreateIngressOperators

func CreateIngressOperators(read func() ([]byte, error)) error

CreateIngressOperators - provides creation of ingress operators from a []byte

func InitEgressOperators

func InitEgressOperators(config []accessdata.Operator) error

InitEgressOperators - allows configuration of access accesslog attributes for egress traffic

func InitIngressOperators

func InitIngressOperators(config []accessdata.Operator) error

InitIngressOperators - allows configuration of access accesslog attributes for ingress traffic

func ReadOperators

func ReadOperators(buf []byte) ([]accessdata.Operator, error)

ReadOperators - read the operators from a []byte

func SetEgressLogStatus

func SetEgressLogStatus(enabled bool)

SetEgressLogStatus - enable/disable egress logging

func SetIngressLogStatus

func SetIngressLogStatus(enabled bool)

SetIngressLogStatus - enable/disable ingress logging

func SetPingLogStatus

func SetPingLogStatus(enabled bool)

SetPingLogStatus - enable/disable ping logging

func Write

Write - templated function handling writing the access data utilizing the OutputHandler and Formatter

Types

type DebugOutputHandler

type DebugOutputHandler struct{}

DebugOutputHandler - output to stdio

func (DebugOutputHandler) Write

func (DebugOutputHandler) Write(items []accessdata.Operator, data *accessdata.Entry, formatter accessdata.Formatter)

type LogOutputHandler

type LogOutputHandler struct{}

LogOutputHandler - output to accesslog

func (LogOutputHandler) Write

func (LogOutputHandler) Write(items []accessdata.Operator, data *accessdata.Entry, formatter accessdata.Formatter)

type NilOutputHandler

type NilOutputHandler struct{}

NilOutputHandler - no output

func (NilOutputHandler) Write

type OutputHandler

type OutputHandler interface {
	Write(items []accessdata.Operator, data *accessdata.Entry, formatter accessdata.Formatter)
}

OutputHandler - template parameter for accesslog output

Example
package main

import (
	"fmt"
	"github.com/gotemplates/host/accessdata"
)

func main() {
	fmt.Printf("test: Output[NilOutputHandler,data.TextFormatter](nil,nil)\n")
	logTest[NilOutputHandler, accessdata.TextFormatter](nil, nil)

	fmt.Printf("test: Output[DebugOutputHandler,data.JsonFormatter](operators,data)\n")
	ops := []accessdata.Operator{{"error", "message"}}
	logTest[DebugOutputHandler, accessdata.JsonFormatter](ops, accessdata.NewEmptyEntry())

	fmt.Printf("test: Output[TestOutputHandler,data.JsonFormatter](nil,nil)\n")
	logTest[TestOutputHandler, accessdata.JsonFormatter](nil, nil)

	fmt.Printf("test: Output[TestOutputHandler,data.JsonFormatter](ops,data)\n")
	logTest[TestOutputHandler, accessdata.JsonFormatter](ops, accessdata.NewEmptyEntry())

	fmt.Printf("test: Output[LogOutputHandler,data.JsonFormatter](ops,data)\n")
	logTest[LogOutputHandler, accessdata.JsonFormatter](ops, accessdata.NewEmptyEntry())

}

func logTest[O OutputHandler, F accessdata.Formatter](items []accessdata.Operator, data *accessdata.Entry) {
	var o O
	var f F
	o.Write(items, data, f)
}
Output:

test: Output[NilOutputHandler,data.TextFormatter](nil,nil)
test: Output[DebugOutputHandler,data.JsonFormatter](operators,data)
{"error":"message"}
test: Output[TestOutputHandler,data.JsonFormatter](nil,nil)
test: Write() -> [{}]
test: Output[TestOutputHandler,data.JsonFormatter](ops,data)
test: Write() -> [{"error":"message"}]
test: Output[LogOutputHandler,data.JsonFormatter](ops,data)

type TestOutputHandler

type TestOutputHandler struct{}

TestOutputHandler - special use case of DebugOutputHandler for testing examples

func (TestOutputHandler) Write

func (TestOutputHandler) Write(items []accessdata.Operator, data *accessdata.Entry, formatter accessdata.Formatter)

Jump to

Keyboard shortcuts

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