Documentation
¶
Index ¶
- Variables
- func Caller(skip int) (string, int)
- func DLog(skip int, cfn func(a ...interface{}) string, msg ...interface{})
- func DummyErrorLog(msg ...interface{})
- func DummyLog(msg ...interface{})
- func DumpCallerStack()
- func DumpCallerWithKey(args ...string)
- func GetCallerStack() string
- func Initialize(opts ...XOptFunc)
- func InitializeWithColor(opts ...XOptFunc)
- func JsonToYaml(raw string) (string, error)
- func MustJsonToYaml(raw string) string
- func MustPrettyYaml(raw string, opts ...PrettyOptFunc)
- func PrettyJSON(rawJson string, opts ...PrettyOptFunc) error
- func PrettyJsonAsYaml(rawJson string, opts ...PrettyOptFunc)
- func PrettyMap(obj map[string]interface{}, opts ...PrettyOptFunc) error
- func PrettyStruct(data any) error
- func PrettyYaml(rawYaml string, opts ...PrettyOptFunc) error
- func PrintToStderr(format string, a ...any)
- func PrintToStdout(format string, a ...any)
- func RecoverAndDumpOnly()
- func RecoverWithCb(cb func())
- func SetNoColor(b bool)
- type PrettyOptFunc
- type PrettyOpts
- type XOptFunc
- type XOpts
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RedPrintf = color.New(color.FgRed, color.Bold).PrintfFunc() CyanPrintf = color.New(color.FgCyan, color.Bold).PrintfFunc() YellowPrintf = color.New(color.FgYellow, color.Bold).PrintfFunc() GreenPrintf = color.New(color.FgGreen, color.Bold).PrintfFunc() )
View Source
var ( RedPrintln = color.New(color.FgRed, color.Bold).PrintlnFunc() CyanPrintln = color.New(color.FgCyan, color.Bold).PrintlnFunc() YellowPrintln = color.New(color.FgYellow, color.Bold).PrintlnFunc() GreenPrintln = color.New(color.FgGreen, color.Bold).PrintlnFunc() Println = fmt.Println )
View Source
var ( Red = color.New(color.FgRed, color.Bold).SprintFunc() Redf = color.New(color.FgRed, color.Bold).SprintfFunc() Green = color.New(color.FgGreen, color.Bold).SprintFunc() Greenf = color.New(color.FgGreen, color.Bold).SprintfFunc() White = color.New(color.FgHiWhite, color.Bold).SprintFunc() Whitef = color.New(color.FgHiWhite, color.Bold).SprintfFunc() Yellow = color.New(color.FgYellow, color.Bold).SprintFunc() Yellowf = color.New(color.FgYellow, color.Bold).SprintfFunc() Cyan = color.New(color.FgCyan, color.Bold).SprintFunc() Cyanf = color.New(color.FgCyan, color.Bold).SprintfFunc() )
View Source
var ( Redfu = color.New(color.FgRed, color.Bold, color.Underline).SprintfFunc() Redfc = color.New(color.FgRed, color.Bold, color.CrossedOut).SprintfFunc() )
Redfu means red foreground with bold underline
Functions ¶
func Caller ¶
Caller wraps runtime.Caller and returns file and line number information
skip:
- 0: Caller
- 1: is where Caller is called
Returns: filename, linenum
func DummyErrorLog ¶
func DummyErrorLog(msg ...interface{})
DummyErrorLog will print a dummy log with red bg
func DumpCallerStack ¶
func DumpCallerStack()
func DumpCallerWithKey ¶
func DumpCallerWithKey(args ...string)
DumpCallerStack
print the caller tree
func GetCallerStack ¶
func GetCallerStack() string
func Initialize ¶
func Initialize(opts ...XOptFunc)
Initialize setups
- color: used for `terminal vivid output`, true by default
- dummyLog: used in `DummyLog`, true by default
func InitializeWithColor ¶
func InitializeWithColor(opts ...XOptFunc)
func JsonToYaml ¶
func MustJsonToYaml ¶
func MustPrettyYaml ¶
func MustPrettyYaml(raw string, opts ...PrettyOptFunc)
func PrettyJSON ¶
func PrettyJSON(rawJson string, opts ...PrettyOptFunc) error
func PrettyJsonAsYaml ¶
func PrettyJsonAsYaml(rawJson string, opts ...PrettyOptFunc)
func PrettyMap ¶
func PrettyMap(obj map[string]interface{}, opts ...PrettyOptFunc) error
func PrettyYaml ¶
func PrettyYaml(rawYaml string, opts ...PrettyOptFunc) error
func PrintToStderr ¶ added in v0.1.1
func PrintToStdout ¶ added in v0.1.1
func RecoverAndDumpOnly ¶
func RecoverAndDumpOnly()
func RecoverWithCb ¶
func RecoverWithCb(cb func())
func SetNoColor ¶
func SetNoColor(b bool)
Types ¶
type PrettyOptFunc ¶
type PrettyOptFunc func(o *PrettyOpts)
func WithFilterKey ¶
func WithFilterKey(s string) PrettyOptFunc
func WithIndent ¶
func WithIndent(i int) PrettyOptFunc
func WithLineNumber ¶
func WithLineNumber(b bool) PrettyOptFunc
type PrettyOpts ¶
type PrettyOpts struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.