log

package module
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: MIT Imports: 6 Imported by: 13

README

Coverage Vulnerabilities Bugs Maintainability Rating

Simple Log

Simple wrapper around zeroLog logger with simple interface for most common use cases

Additionally a [logr]https://github.com/go-logr/logr compliant interface can be instantiated with the same "constructor" signature as the standard implementation.

Exposes 3 log levels and returns an instance of a logger with set-able level and writer.

  • DEBUG
  • INFO
  • ERROR

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogr added in v1.6.0

func NewLogr(writer io.Writer, lvl LogLevel) logr.Logger

Types

type LogLevel

type LogLevel string
const (
	DebugLvl LogLevel = "debug"
	InfoLvl  LogLevel = "info"
	ErrorLvl LogLevel = "error"
)

func ParseLevel added in v1.2.0

func ParseLevel(lvl string) LogLevel

ParseLevel returns a LogLevel if found by string If not found will default to error possible values are `error`, `debug`, `info`

type Logger

type Logger struct {
	Loggeriface
	// contains filtered or unexported fields
}

func New

func New(writer io.Writer, lvl LogLevel) Logger

New returns a configured instance of ZeroLog with minimal methods.

func (Logger) Debug

func (l Logger) Debug(msg string)

func (Logger) Debugf

func (l Logger) Debugf(format string, args ...any)

func (Logger) Error

func (l Logger) Error(err error)

func (Logger) Errorf

func (l Logger) Errorf(format string, args ...any)

func (Logger) Info

func (l Logger) Info(msg string)

func (Logger) Infof

func (l Logger) Infof(format string, args ...any)

func (Logger) Level added in v1.2.0

func (l Logger) Level() LogLevel

Level returns the current logging level of the instance

func (Logger) Writer added in v1.2.0

func (l Logger) Writer() io.Writer

Writer returns the current writer of the logging instance

type Loggeriface

type Loggeriface interface {
	Debugf(format string, args ...any)
	Debug(msg string)
	Infof(format string, args ...any)
	Info(msg string)
	Errorf(format string, args ...any)
	Error(err error)
}

Jump to

Keyboard shortcuts

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