github.com/searKing/golang/go@v1.2.117/log/log.go (about) 1 // Copyright 2021 The searKing Author. 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 6 7 // The PrintfFunc type is an adapter to allow the use of 8 // ordinary functions as Printf handlers. If f is a function 9 // with the appropriate signature, PrintfFunc(f) is a 10 // Handler that calls f. 11 type PrintfFunc func(format string, a ...any) 12 13 // Write calls f(p). 14 func (f PrintfFunc) Write(p []byte) (n int, err error) { 15 f("%s", string(p)) 16 return len(p), nil 17 }