github.com/euank/go@v0.0.0-20160829210321-495514729181/src/log/example_test.go (about)

     1  // Copyright 2013 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package log_test
     6  
     7  import (
     8  	"bytes"
     9  	"fmt"
    10  	"log"
    11  )
    12  
    13  func ExampleLogger() {
    14  	var buf bytes.Buffer
    15  	logger := log.New(&buf, "logger: ", log.Lshortfile)
    16  	logger.Print("Hello, log file!")
    17  
    18  	fmt.Print(&buf)
    19  	// Output:
    20  	// logger: example_test.go:16: Hello, log file!
    21  }