logx

package
v0.1.73 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 19

Documentation

Overview

Package logx provides very useful utilities for logging. I hesitate to create it, for fear we will add too much stuff to it. But LogEvery seems worth it. This packages uses the MIT license, to respect the corresponding license from kami-zh/go-capture

Index

Constants

This section is empty.

Variables

View Source
var Debug = log.New(ioutil.Discard, "DEBUG: ", 0)

Debug is the package logger for debug messages. Debug messages are discarded if LogxDebug is set false.

View Source
var (
	// LogxDebug controls whether the debug logger is enabled or not. In almost all cases
	// you should rely on the flag to change this value. If critical, you may change the
	// value using LogxDebug.Set("true") or LogxDebug.Set("false").
	LogxDebug = logxDebug(false)
)

Functions

func CaptureLog

func CaptureLog(logger *log.Logger, f func()) (string, error)

CaptureLog captures all output from log.Println, etc. Adapted from github.com/kami-zh

Types

type Logger

type Logger interface {
	Println(v ...interface{})
	Printf(fmt string, v ...interface{})
}

A Logger has basic Printf and Println functions.

func NewLogEvery

func NewLogEvery(logger *log.Logger, interval time.Duration) Logger

NewLogEvery creates a logger that will log not more than once every interval.

Jump to

Keyboard shortcuts

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