wglog

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 5 Imported by: 1

README

wglog

Go Reference

This is a set of extensions for Wireguard-go's logger.

Installation

To use wglog in your Go project, install it using go get:

go get github.com/point-c/wglog

Loggers

  • noop: Non-nil logger that does nothing.
  • slog: Converts a slog.Logger to a device.Logger.
    • Logging is done on the following levels:
      • Verbosef
        • slog.LevelDebug
      • Errorf
        • slog.LevelError
  • multi: Emits log messages on multiple loggers.
  • async: Runs the logger funcs in a goroutine.

Testing

The package includes tests that demonstrate its functionality. Use Go's testing tools to run the tests:

go test

Godocs

To regenerate godocs:

go generate -tags docs ./...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Async

func Async(logger *device.Logger) *device.Logger

Async will call the underlying logger methods in a goroutine. If a field in logger is nil, it will not spawn a goroutine.

func Multi

func Multi(loggers ...*device.Logger) *device.Logger

Multi will emit a logged message on all given loggers.

func Noop

func Noop() *device.Logger

Noop is a logger that does not output anything. The logger and both of its funcs are not nil.

func Slog

func Slog(logger *slog.Logger) *device.Logger

Slog creates a device.Logger instance that is backed by a specified slog.Logger. No args are passed to the slog logger, instead the message is created from the format string and args passed to the device.Logger.Verbosef and device.Logger.Errorf funcs. Verbose messages are logged at the Debug level, while errors are logged at the Error level.

Types

type FmtFn added in v0.1.0

type FmtFn func(string, ...any)

FmtFn is a function capable of outputting a printf style string.

Jump to

Keyboard shortcuts

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