Skip to content

Latest commit

 

History

History

L

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

L

-- import "github.com/kokizzu/gotro/L"

Usage

const WebBR = "\n<br/>"
var BgRed, BgGreen (func(format string, a ...any) string)
var CPU_PERCENT, RAM_PERCENT float64
var CPU_STAT2, CPU_STAT4, CPU_STAT5, LAST_STAT7 int64
var DEBUG bool
var FILE_PATH string
var GO_PATH string
var GO_ROOT string
var IsError = DefaultIsError

IsError print error

var LAST_CPU_CALL, LAST_RAM_CALL int64
var LOG *logging.Logger
var NUM_CPU float64
var TIMETRACK_MIN_DURATION float64

func CheckIf

func CheckIf(isErr bool, msg string, args ...any) bool

CheckIf print error

func CreateDir

func CreateDir(path string) bool

CreateDir create directory recursively

func CreateFile

func CreateFile(path string, content string) bool

CreateFile create file with specific content

func DefaultIsError

func DefaultIsError(err error, msg string, args ...any) bool

DefaultIsError function that prints error with stacktrace

func Describe

func Describe(args ...any)

Describe pretty print any variable

func FileEmpty

func FileEmpty(name string) bool

FileEmpty check file missing or has zero size

func FileExists

func FileExists(name string) bool

FileExists check file exists

func LogTrack

func LogTrack(start time.Time, name string) float64

LogTrack return elapsed time in ms, show 3nd level, returns in ms

func Panic

func Panic(msg string, args ...any)

PanicIf print error message and exit program

func PanicIf

func PanicIf(err error, msg string, args ...any)

PanicIf print error message and exit program

func ParentDescribe

func ParentDescribe(args ...any)

ParentDescribe describe anything

func PercentCPU

func PercentCPU() float64

PercentCPU get CPU usage percentage

L.PercentCPU()

func PercentRAM

func PercentRAM() float64

PercentRAM get RAM usage percentage

L.PercentRAM()

func PipeRunCmd

func PipeRunCmd(cmd string, args ...string) error

PipeRunCmd run cmd and pipe to stdout

func Print

func Print(any ...any)

Print replacement for fmt.Println, gives line number

func PrintParent

func PrintParent(any ...any)

PrintParent print but show grandparent caller function

func ReadFile

func ReadFile(path string) string

ReadFile read file content as string

func ReadFileLines

func ReadFileLines(path string, eachLineFunc func(line string) (exitEarly bool)) (ok bool)

ReadFileLines read file content line by line

func RunCmd

func RunCmd(cmd string, args ...string) (output []byte)

RunCmd execute command and return output

func StackTrace

func StackTrace(start int) string

StackTrace get a stacktrace as string

L.StackTrace(0) // until current function
L.StackTrace(1) // until function that call this function

func TimeTrack

func TimeTrack(start time.Time, name string) float64

TimeTrack return elapsed time in ms, show 1st level, returns in ms

func Trace

func Trace()

Trace trace a function call

type CallInfo

type CallInfo struct {
	PackageName string
	FileName    string
	FuncName    string
	Line        int
}

func CallerChain

func CallerChain(skipFrom, skipUntil int) (res []CallInfo)

CallerChain return caller chain until specific skipFrom 1 to 2 will return from parent caller until grandparent

func CallerInfo

func CallerInfo(skip ...int) (caller *CallInfo)

CallerInfo return caller info default skip is 1, equal to parent caller

func (*CallInfo) String

func (c *CallInfo) String() string