target_network

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	DefaultNetworkType    = `tcp`
	DefaultNetworkAddress = ``
)

Functions

This section is empty.

Types

type NetworkTarget

type NetworkTarget struct {
	*log.Filter
	// the network to connect to. Valid networks include
	// tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only),
	// "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4"
	// (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and
	// "unixpacket".
	Network string
	// the address on the network to connect to.
	// For TCP and UDP networks, addresses have the form host:port.
	// If host is a literal IPv6 address it must be enclosed
	// in square brackets as in "[::1]:80" or "[ipv6-host%zone]:80".
	Address string
	// whether to use a persistent network connection.
	// If this is false, for every message to be sent, a network
	// connection will be open and closed.
	Persistent bool
	// the size of the message channel.
	BufferSize int
	// contains filtered or unexported fields
}

NetworkTarget sends log messages over a network connection.

func NewNetworkTarget

func NewNetworkTarget() *NetworkTarget

NewNetworkTarget creates a NetworkTarget. The new NetworkTarget takes these default options: MaxLevel: LevelDebug, Persistent: true, BufferSize: 1024. You must specify the Network and Address fields.

Example
logger := log.NewLogger()

// creates a NetworkTarget which uses tcp network and address :10234
target := NewNetworkTarget()
target.Network = "tcp"
target.Address = ":10234"

logger.Targets = append(logger.Targets, target)

logger.Open()

// ... logger is ready to use ...

func (*NetworkTarget) Close

func (t *NetworkTarget) Close()

Close closes the network target.

func (*NetworkTarget) Open

func (t *NetworkTarget) Open(errWriter io.Writer) error

Open prepares NetworkTarget for processing log messages.

func (*NetworkTarget) Process

func (t *NetworkTarget) Process(e *log.Entry)

Process puts filtered log messages into a channel for sending over network.

Jump to

Keyboard shortcuts

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