utils

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLog

func AddLog(l1 _log.Logger)

AddLog to add logger chain.

func Ellipsis

func Ellipsis(str string, length int) string

Ellipsis to truncate string.

func Error

func Error(str string, args ...interface{})

Error to print error.

func Fatal

func Fatal(str string, args ...interface{})

Fatal to log fatal.

func GetKey

func GetKey(params ...interface{}) string

GetKey to generate cache key.

func GetLogger

func GetLogger(i ...int) _log.Logger

GetLogger to get logger.

func Info

func Info(str string, args ...interface{})

Info to log info.

func InitLog

func InitLog(lvl LogLevel, json, color bool)

InitLog to init global logger.

func Log

func Log(field map[string]interface{})

Log to log with custom field.

func PadLeft

func PadLeft(str string, l int, p string) string

PadLeft to pad string to the left.

func PadRight

func PadRight(str string, l int, p string) string

PadRight to pad string to the right.

func ParseDuration added in v0.0.2

func ParseDuration(isoDuration string) time.Duration

ParseDuration parses an ISO 8601 string representing a duration, and returns the resultant golang time.Duration instance.

func Repeat

func Repeat(str string, n int) string

Repeat to repeat string.

func Thousands added in v0.0.2

func Thousands(num int) string

Thousands to format int to thousands string format.

Types

type LogLevel added in v1.4.4

type LogLevel int8

LogLevel is level of log that will be printed. Will print level that is higher than your chosen one.

const (
	TraceLevel LogLevel = iota - 1
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
	PanicLevel
	Disabled
)

Available log level.

Jump to

Keyboard shortcuts

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