Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
example_test.go42 linesDownload Raw Back to log
1// Copyright 2013 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.4 5package log_test6 7import (8	"bytes"9	"fmt"10	"log"11)12 13func ExampleLogger() {14	var (15		buf    bytes.Buffer16		logger = log.New(&buf, "logger: ", log.Lshortfile)17	)18 19	logger.Print("Hello, log file!")20 21	fmt.Print(&buf)22	// Output:23	// logger: example_test.go:19: Hello, log file!24}25 26func ExampleLogger_Output() {27	var (28		buf    bytes.Buffer29		logger = log.New(&buf, "INFO: ", log.Lshortfile)30 31		infof = func(info string) {32			logger.Output(2, info)33		}34	)35 36	infof("Hello world")37 38	fmt.Print(&buf)39	// Output:40	// INFO: example_test.go:36: Hello world41}42 
codekingpro/portable-devtools · Team Ai