util

package
v0.0.2-0...-4ce78c8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHostname

func GetHostname(hostname string) (string, error)

TODO: get hostname from command

func LogName

func LogName(pluginType, name, alias string) string

LogName returns the log-friendly name/type.

func Prettify

func Prettify(i interface{}) string

Prettify returns the string representation of a value.

func SanitizeMetric

func SanitizeMetric(s string) string

func SanitizeTag

func SanitizeTag(s string) string

func SanitizeTags

func SanitizeTags(tags []string) []string

func SetLoggerOnPlugin

func SetLoggerOnPlugin(i interface{}, log api.Logger)

func SleepContext

func SleepContext(ctx context.Context, duration time.Duration) error

SleepContext sleeps until the context is closed or the duration is reached.

Types

type Logger

type Logger struct {
	OnErrs []func()
	Name   string // Name is the plugin name, will be printed in the `[]`.
}

Logger defines a logging structure for plugins.

func NewLogger

func NewLogger(pluginType, name, alias string) *Logger

NewLogger creates a new logger instance

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug logs a debug message, patterned after klog.Info.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs a debug message, patterned after klog.Infof.

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error logs an error message, patterned after klog.Info.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs an error message, patterned after klog.Infof.

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info logs an information message, patterned after klog.Info.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof logs an information message, patterned after klog.Infof.

func (*Logger) OnErr

func (l *Logger) OnErr(f func())

OnErr defines a callback that triggers only when errors are about to be written to the log

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

Warn logs a warning message, patterned after klog.Info.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf logs a warning message, patterned after klog.Infof.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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