util

package
v0.0.0-...-a197711 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRACE = iota
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
)

Log Level

Variables

This section is empty.

Functions

func FilePath

func FilePath(file string) (real string, err error)

FilePath gives the real file path. If is a link, gives its origin path.

func GetPasswd

func GetPasswd() []byte

GetPasswd Only Available in *nix OS

func IsDir

func IsDir(path string) bool

IsDir gives whether @path is a directory

func JustifyText

func JustifyText(text string, width int) []string

JustifyText splits a string into array with each item has the same length.

func SplitBySpace

func SplitBySpace(str string) []string

SplitBySpace split a string with /\s+/

func WrapCmd

func WrapCmd(cmd, before, after string) string

WrapCmd returns `before && cmd && after`

func WrapCmdAfter

func WrapCmdAfter(cmd, after string) string

WrapCmdAfter appends `&& after` for cmd

func WrapCmdBefore

func WrapCmdBefore(cmd, before string) string

WrapCmdBefore adds `before &&` before cmd

Types

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

Logger is a simple logger

func NewLogger

func NewLogger(filepath string) (logger *Logger)

NewLogger returns a logger @filepath log's full path, mkdirp if dirname does not exists. Use stdout if is empty.

func (*Logger) Debug

func (logger *Logger) Debug(format string, v ...interface{})

Debug : logger.Debug

func (*Logger) Fatal

func (logger *Logger) Fatal(format string, v ...interface{})

Fatal : logger.Fatal

func (*Logger) Info

func (logger *Logger) Info(format string, v ...interface{})

Info : logger.Info

func (*Logger) Log

func (logger *Logger) Log(prefix string, format string, v ...interface{})

Log : arbitrary log

func (*Logger) SetLevel

func (logger *Logger) SetLevel(level int)

SetLevel is a level setter

func (*Logger) Trace

func (logger *Logger) Trace(format string, v ...interface{})

Trace : logger.Trace

func (*Logger) Warn

func (logger *Logger) Warn(format string, v ...interface{})

Warn : logger.Warn

Jump to

Keyboard shortcuts

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