util

package
v0.15.0-1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIGHUP  = 0x1
	SIGINT  = 0x2
	SIGQUIT = 0x3
	SIGTERM = 0xF
)
View Source
const (
	TimeFormat = "2006-01-02T15:04:05.000Z"
)
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
)
View Source
var Colors = [...]int{
	alog.DebugLevel: green,
	alog.InfoLevel:  blue,
	alog.WarnLevel:  yellow,
	alog.ErrorLevel: red,
	alog.FatalLevel: red,
}

Colors mapping.

View Source
var Strings = [...]string{
	alog.DebugLevel: "D",
	alog.InfoLevel:  "I",
	alog.WarnLevel:  "W",
	alog.ErrorLevel: "E",
	alog.FatalLevel: "F",
}

Strings mapping.

Functions

func Backtrace

func Backtrace(size int) []string

Backtrace gathers a backtrace for the caller. Return a slice of up to N stack frames.

func Darwin

func Darwin() bool

func Debug

func Debug(arg string)

Verbosity level helps track down production issues:

-l debug

func Debugf

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

Verbosity level helps track down production issues:

-l debug

func EnsureChildShutdown

func EnsureChildShutdown(cmd *exec.Cmd, sig int)

func Error

func Error(msg string, err error)

func FileExists

func FileExists(path string) (bool, error)

FileExists checks if given file exists

func Info

func Info(arg string)

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 MemoryUsage

func MemoryUsage() 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(arg string)

Uh oh, not good but not worthy of process death

func Warnf

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

Types

type LogHandler

type LogHandler struct {
	// contains filtered or unexported fields
}

func (*LogHandler) HandleLog

func (h *LogHandler) HandleLog(e *alog.Entry) error

type Logger

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

	// Log and terminate process (unrecoverable)
	Fatal(arg string)

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

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

	// Set key/value context for further logging with the returned logger
	WithFields(keyValues alog.Fielder) *alog.Entry

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

This generic logging interface hide a Logrus logger or another impl

func Log

func Log() Logger

func NewLogger

func NewLogger(level string, production bool) Logger

Jump to

Keyboard shortcuts

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