util

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2017 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// This is the canonical timestamp format used by Faktory.
	// Always UTC, lexigraphically sortable.  This is the best
	// timestamp format, accept no others.
	TimestampFormat = time.RFC3339Nano
)

Variables

View Source
var (
	LogInfo  = false
	LogDebug = false
)

Functions

func Backtrace

func Backtrace(size int) []string

* Gather a backtrace for the caller. * Return a slice of up to N stack frames.

func Darwin

func Darwin() bool

func Debug

func Debug(args ...interface{})

-l debug: Verbosity level which helps track down production issues

func Debugf

func Debugf(msg string, args ...interface{})

-l debug: Verbosity level which helps track down production issues

func Error

func Error(msg string, err error, stack []byte)

func FileExists

func FileExists(path string) (bool, error)

func Info

func Info(args ...interface{})

Typical logging output, the default level

func Infof

func Infof(msg string, args ...interface{})

Typical logging output, the default level

func InitLogger

func InitLogger(level string)

func Nows

func Nows() string

func ParseTime

func ParseTime(str string) (time.Time, error)

func RandomJid

func RandomJid() string

func ReadLines

func ReadLines(data []byte) ([]string, error)

readLines reads a whole file into memory and returns a slice of its lines.

func Thens

func Thens(tim time.Time) string

func Warn

func Warn(args ...interface{})

Uh oh, not good but not worthy of process death

func Warnf

func Warnf(msg string, args ...interface{})

Types

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})

	// Log and terminate process (unrecoverable)
	Fatal(args ...interface{})

	// Log with fmt.Printf-like formatting and terminate process (unrecoverable)
	Fatalf(format string, args ...interface{})

	// Log and panic (recoverable)
	Panic(args ...interface{})

	// Log with fmt.Printf-like formatting, then panic (recoverable)
	Panicf(format string, args ...interface{})

	// Set key/value context for further logging with the returned logger
	WithField(key string, value interface{}) Logger

	// Set key/value context for further logging with the returned logger
	WithFields(keyValues map[string]interface{}) Logger

	// Return a logger with the specified error set, to be included in a subsequent normal logging call
	WithError(err error) Logger
}

This generic logging interface hide a Logrus logger or another impl

func Log

func Log() Logger

func NewLogger

func NewLogger(level string, takeOverLog bool) Logger

Jump to

Keyboard shortcuts

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