|
|
|
@ -19,6 +19,7 @@ |
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"errors" |
|
|
|
|
"fmt" |
|
|
|
|
"math" |
|
|
|
|
"math/big" |
|
|
|
@ -39,6 +40,12 @@ var logTestCommand = &cli.Command{ |
|
|
|
|
This command is only meant for testing. |
|
|
|
|
`} |
|
|
|
|
|
|
|
|
|
type customQuotedStringer struct { |
|
|
|
|
} |
|
|
|
|
func (c customQuotedStringer) String() string { |
|
|
|
|
return "output with 'quotes'" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// logTest is an entry point which spits out some logs. This is used by testing
|
|
|
|
|
// to verify expected outputs
|
|
|
|
|
func logTest(ctx *cli.Context) error { |
|
|
|
@ -70,6 +77,8 @@ func logTest(ctx *cli.Context) error { |
|
|
|
|
log.Info("uint64", "18,446,744,073,709,551,615", uint64(math.MaxUint64)) |
|
|
|
|
} |
|
|
|
|
{ // Special characters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.Info("Special chars in value", "key", "special \r\n\t chars") |
|
|
|
|
log.Info("Special chars in key", "special \n\t chars", "value") |
|
|
|
|
|
|
|
|
@ -83,9 +92,13 @@ func logTest(ctx *cli.Context) error { |
|
|
|
|
|
|
|
|
|
colored := fmt.Sprintf("\u001B[%dmColored\u001B[0m[", 35) |
|
|
|
|
log.Info(colored, colored, colored) |
|
|
|
|
err := errors.New("this is an 'error'") |
|
|
|
|
log.Info("an error message with quotes", "error", err) |
|
|
|
|
} |
|
|
|
|
{ // Custom Stringer() - type
|
|
|
|
|
log.Info("Custom Stringer value", "2562047h47m16.854s", common.PrettyDuration(time.Duration(9223372036854775807))) |
|
|
|
|
var c customQuotedStringer |
|
|
|
|
log.Info("a custom stringer that emits quoted text", "output", c) |
|
|
|
|
} |
|
|
|
|
{ // Lazy eval
|
|
|
|
|
log.Info("Lazy evaluation of value", "key", log.Lazy{Fn: func() interface{} { return "lazy value" }}) |
|
|
|
|