lg

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

lg implements a simple verbosity logger interface.

The default verbosity is 0, and can be changed by setting the environment variable GGEN_LOGGING. For example:

GGEN_LOGGING=1          : set the current verbosity to 1

logger.V(0).Printf(...) : print log, since V(0) >  GGEN_LOGGING
logger.V(1).Printf(...) : print log, since V(1) == GGEN_LOGGING
logger.V(2).Printf(...) : not print, since V(2) >  GGEN_LOGGING

User of ggen package can replace the default logger with their own implementation by implementing the Logger interface.

Index

Constants

This section is empty.

Variables

View Source
var New func() Logger

Functions

This section is empty.

Types

type Logger

type Logger interface {

	// Verbosed checks if the current verbosity level is equal or higher than the param.
	Verbosed(verbosity int) bool

	// V returns a VerbosedLogger, which only outputs log when the current verbosity level is equal or higher than the
	// log line verbosity.
	V(verbosity int) VerbosedLogger

	// GetV returns the current verbosity.
	GetV() int

	// SetV sets a new verbosity, and return the last verbosity. The new verbosity must be equal or larger than the
	// current verbosity.
	SetV(verbosity int) int
}

type VerbosedLogger

type VerbosedLogger interface {
	Print(args ...interface{})
	Printf(format string, args ...interface{})
	Println(args ...interface{})
}

Jump to

Keyboard shortcuts

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