util

package
Version: v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NeverStop <-chan struct{} = make(chan struct{})

NeverStop may be passed to Until to make it never stop.

View Source
var PanicHandlers = []func(interface{}){logPanic}

PanicHandlers is a list of functions which will be invoked when a panic happens.

View Source
var ReallyCrash bool

For testing, bypass HandleCrash.

Functions

func Dump

func Dump(v interface{})

Dump object

func FlushLogs

func FlushLogs()

FlushLogs flushes logs immediately.

func HandleCrash

func HandleCrash(additionalHandlers ...func(interface{}))

HandleCrash simply catches a crash and logs an error. Meant to be called via defer. Additional context-specific handlers can be provided, and will be called in case of panic

func InitLogs

func InitLogs()

InitLogs initializes logs the way we want for kubernetes.

func IsFileExist

func IsFileExist(fpath string) bool

IsFileExist reports whether path exits.

func IsSameConfig

func IsSameConfig(src, dest string) (bool, error)

IsSameConfig reports whether src and dest config files are equal. Two config files are equal when they have the same file contents and Unix permissions. The owner, group, and mode must match. It return false in other cases.

func NewLogger

func NewLogger(prefix string) *log.Logger

NewLogger creates a new log.Logger which sends logs to glog.Info.

func Until

func Until(f func(), period time.Duration, stopCh <-chan struct{})

Until loops until stop channel is closed, running f every period. Catches any panics, and keeps going. f may not be invoked if stop channel is already closed. Pass NeverStop to Until if you don't want it stop.

Types

type GlogWriter

type GlogWriter struct{}

GlogWriter serves as a bridge between the standard log package and the glog package.

func (GlogWriter) Write

func (writer GlogWriter) Write(data []byte) (n int, err error)

Write implements the io.Writer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL