github.com/quay/claircore@v1.5.28/docs/logger_test.go (about)

     1  package docs_test
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	"github.com/quay/zlog"
     8  )
     9  
    10  // Example_logger is an example annotated for inclusion in the prose
    11  // documentation.
    12  func Example_logger() {
    13  	ctx := context.Background()
    14  	// ANCHOR: kvs
    15  	ctx = zlog.ContextWithValues(ctx,
    16  		"component", "Example.Logger")
    17  	// ANCHOR_END: kvs
    18  
    19  	// ANCHOR: bad_example
    20  	zlog.Info(ctx).Msgf("done at: %v", time.Now())
    21  	// ANCHOR_END: bad_example
    22  	// ANCHOR: good_example
    23  	zlog.Info(ctx).
    24  		Time("time", time.Now()).
    25  		Msgf("done")
    26  	// ANCHOR_END: good_example
    27  }