Documentation ¶
Overview ¶
Example ¶
package main import ( "fmt" "os" "github.com/go-logr/logr" "github.com/go-logr/zapr" "github.com/task4233/dl" "go.uber.org/zap" ) func main() { num := 123 name := "dl" dl.Fprintln(os.Stdout, "num: ", num) dl.Println("num: ", num) dl.Fprintf(os.Stdout, "name: %s\n", name) dl.Printf("name: %s", name) 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
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fprintf ¶
Fprintf formats according to a format specifier and writes to w. Arguments are handled in the manner of fmt.FPrintf.
Example ¶
package main import ( "os" "github.com/task4233/dl" ) func main() { 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 ¶
package main import ( "os" "github.com/task4233/dl" ) func main() { type person struct { name string age int } alice := person{ name: "alice", age: 15, } dl.Fprintln(os.Stdout, "name:", alice.name) }
Output: name: alice
func Printf ¶
Printf calls Fprintf to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
Example ¶
package main import ( "github.com/task4233/dl" ) func main() { 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) }
Output:
func Println ¶
Println calls Fprintln to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
Example ¶
package main import ( "github.com/task4233/dl" ) func main() { 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) }
Output:
Types ¶
type Logger ¶ added in v0.5.8
Logger is a struct for preserving *logr.Logger.
func NewLogger ¶ added in v0.5.8
NewLogger wraps logr.Logger.
Example ¶
package main import ( "fmt" "github.com/go-logr/logr" "github.com/go-logr/zapr" "github.com/task4233/dl" "go.uber.org/zap" ) func main() { 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) }
Output:
Click to show internal directories.
Click to hide internal directories.