Documentation
¶
Overview ¶
Example ¶
num := 123
name := "dl"
type MyInt int
var myNum MyInt = 123
dl.Fprintln(os.Stdout, "num: ", num)
dl.Println("num: ", num)
dl.Fprintf(os.Stdout, "name: %s\n", name)
dl.Printf("name: %s", name)
dl.FInfo(os.Stdout, myNum)
dl.Info(myNum)
zapLog, err := zap.NewDevelopment()
if err != nil {
panic(fmt.Sprintf("who watches the watchmen (%v)?", err))
}
var log logr.Logger = zapr.NewLogger(zapLog)
dlr := dl.NewLogger(&log)
dlr.Info("Info: ", "num", num)
Output: num: 123 name: dl [DeLog] info: 123 (dl_test.MyInt) log_example_test.go:23
Index ¶
- func FInfo[T any](w io.Writer, v T) (int, error)
- func Fprintf(w io.Writer, format string, v ...any) (int, error)
- func Fprintln(w io.Writer, v ...any) (int, error)
- func Info[T any](v T) (int, error)
- func Printf(format string, v ...any) (int, error)
- func Println(v ...any) (int, error)
- type CLI
- type Logger
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FInfo ¶
FInfo gives a val, a type, a file name, a line number and writes to w..
Example ¶
type person struct {
name string
age int
}
alice := person{
name: "alice",
age: 15,
}
_, _ = dl.FInfo(os.Stdout, alice)
Output: [DeLog] info: dl_test.person{name:"alice", age:15} (dl_test.person) log_example_test.go:50
func Fprintf ¶
Fprintf formats according to a format specifier and writes to w. Arguments are handled in the manner of fmt.FPrintf.
Example ¶
type person struct {
name string
age int
}
alice := person{
name: "alice",
age: 15,
}
dl.Fprintf(os.Stdout, "name: %s", alice.name)
Output: name: alice
func Fprintln ¶
Fprintln formats using the default formats for its operands and writes to w. Spaces are always added between operands and a newline is appended. Arguments are handled in the manner of fmt.FPrintln.
Example ¶
type person struct {
name string
age int
}
alice := person{
name: "alice",
age: 15,
}
dl.Fprintln(os.Stdout, "name:", alice.name)
Output: name: alice
func Info ¶
Info gives a val, a type, a file name, a line number to print to the standard logger.
Example ¶
type person struct {
name string
age int
}
alice := person{
name: "alice",
age: 15,
}
// dl.Info prints to sandard error.
// [DeLog] info: dl_test.person{name:"alice", age:15} (dl_test.person) log_example_test.go:96
_, _ = dl.Info(alice)
func Printf ¶
Printf calls Fprintf to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
Example ¶
type person struct {
name string
age int
}
alice := person{
name: "alice",
age: 15,
}
// dl.Printf prints to sandard error.
// name: alice
dl.Printf("name: %s", alice.name)
func Println ¶
Println calls Fprintln to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
Example ¶
type person struct {
name string
age int
}
alice := person{
name: "alice",
age: 15,
}
// dl.Printf prints to sandard error.
// name: alice
//
dl.Println("name:", alice.name)
Types ¶
type Logger ¶
Logger is a struct for preserving *logr.Logger.
func NewLogger ¶
NewLogger wraps logr.Logger.
Example ¶
zapLog, err := zap.NewDevelopment()
if err != nil {
panic(fmt.Sprintf("who watches the watchmen (%v)?", err))
}
var log logr.Logger = zapr.NewLogger(zapLog)
// You can use your logr.Logger as it is.
dlr := dl.NewLogger(&log)
num := 57
dlr.Info("Info: ", "num", num)
