common

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginUrl    = "http://%s:7717/v2.2/login"
	LogUrl      = "http://%s:7717/v2.2/logs_upload"
	LogInterval = int(time.Hour * 1)
	LastFile    = "/var/log/datera/last"
	LogFiltered = "/var/log/datera/dlogs.tar.gz"
)
View Source
const (
	ReqName = "req"
	TraceId = "tid"
)

Variables

View Source
var (
	OS         ISystem
	FileReader ReadFile
)

Binding this to an exported function for mocking purposes in tests

View Source
var (
	EndLogging = make(chan bool)
)

Functions

func Debug

func Debug(ctxt context.Context, s interface{})

func Debugf

func Debugf(ctxt context.Context, s string, args ...interface{})

func Error

func Error(ctxt context.Context, s interface{})

func Errorf

func Errorf(ctxt context.Context, s string, args ...interface{})

func ExecC

func ExecC(ctxt context.Context, name string, arg ...string) *exec.Cmd

func Fatal

func Fatal(ctxt context.Context, s interface{})

func Fatalf

func Fatalf(ctxt context.Context, s string, args ...interface{})

func GenId

func GenId() string

func Info

func Info(ctxt context.Context, s interface{})

func Infof

func Infof(ctxt context.Context, s string, args ...interface{})

func LogUploadDaemon

func LogUploadDaemon(ip, username, password, file string, interval int) error

func MkCtxt

func MkCtxt(reqName string) context.Context

func PanicErr

func PanicErr(err error)

func Prettify added in v1.1.3

func Prettify(v interface{}) string

func Tsprint

func Tsprint(s string, m map[string]string) (string, error)

func Unpack

func Unpack(b []byte, m *map[string]interface{}) error

func Warning

func Warning(ctxt context.Context, s interface{})

func Warningf

func Warningf(ctxt context.Context, s string, args ...interface{})

Types

type ISystem

type ISystem interface {
	Lstat(string) (os.FileInfo, error)
	Stat(string) (os.FileInfo, error)
	IsNotExist(error) bool
	MkdirAll(string, os.FileMode) error
}

"OS" interface to allow for mocking purposes in tests If more OS functions are needed, just add them to this interface and the concrete implementation

type ReadFile

type ReadFile func(f string) ([]byte, error)

type System

type System struct {
}

Concrete OS impelmentation

func (System) IsNotExist

func (s System) IsNotExist(e error) bool

func (System) Lstat

func (s System) Lstat(f string) (os.FileInfo, error)

func (System) MkdirAll

func (s System) MkdirAll(f string, o os.FileMode) error

func (System) Stat

func (s System) Stat(f string) (os.FileInfo, error)

Jump to

Keyboard shortcuts

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