io

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 1 Imported by: 3

Documentation

Overview

Package io provides a means of turning a log.Logger into an io.Writer for a chosen level. An example of this would be:

import(
    "io"
    "github.com/Masterminds/log-go"
    logio "github.com/Masterminds/log-go/io"
)

func main() {
    w := logio.NewCurrentWriter(log.InfoLevel)
    io.WriteString(w, "foo")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrentWriter

type CurrentWriter struct {
	Level int
}

CurrentWriter uses the current package level logger for io writing

func NewCurrentWriter

func NewCurrentWriter(level int) *CurrentWriter

NewCurrentWriter creates a new CurrentWriter. The levels that can be passed to it are: - log.TraceLevel: - log.DebugLevel: - log.InfoLevel: - log.WarnLevel: - log.ErrorLevel: - log.PanicLevel: - log.FatalLevel:

func (CurrentWriter) Write

func (l CurrentWriter) Write(p []byte) (n int, err error)

Write is the write method from the io.Writer interface in the standard lib

type Writer

type Writer struct {
	Logger log.Logger
	Level  int
}

Writer uses the configured logger for io writing

func NewWriter

func NewWriter(lgr log.Logger, level int) *Writer

NewWriter creates a new Writer. It accepts a logger and a level that will be written on the io.Writer interface. The levels you can pass in are: - log.TraceLevel: - log.DebugLevel: - log.InfoLevel: - log.WarnLevel: - log.ErrorLevel: - log.PanicLevel: - log.FatalLevel:

func (Writer) Write

func (l Writer) Write(p []byte) (n int, err error)

Write is the write method from the io.Writer interface in the standard lib

Jump to

Keyboard shortcuts

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