Don't export *log.Logger in Scanner
By introducing a lowercase type alias 'logger' for *log.Logger we can now embed 'logger' in Scanner and not export it: % go doc Scanner package symbolyze // import "." type Scanner struct { // Has unexported fields. }
This commit is contained in:
parent
7af1728eed
commit
32981d6a55
@ -28,7 +28,7 @@ type Scanner struct {
|
|||||||
cache map[string]uint64 // Contains (pathname, offset)
|
cache map[string]uint64 // Contains (pathname, offset)
|
||||||
observers []Observer // Callbacks
|
observers []Observer // Callbacks
|
||||||
|
|
||||||
*log.Logger // Embedded logger
|
logger // Embedded logger
|
||||||
|
|
||||||
// Instead of using a boolean to indicate debugging, we use function
|
// Instead of using a boolean to indicate debugging, we use function
|
||||||
// members. This way we can populate them with noop-functions in the
|
// members. This way we can populate them with noop-functions in the
|
||||||
@ -39,6 +39,10 @@ type Scanner struct {
|
|||||||
err error // error state of the scanner.
|
err error // error state of the scanner.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We use a lowercase type alias for *log.Logger so that we can embedd it in
|
||||||
|
// Scanner without exporting it.
|
||||||
|
type logger = *log.Logger
|
||||||
|
|
||||||
// An Observer is a callback that can be registerd with Scanner.OnFound. It
|
// An Observer is a callback that can be registerd with Scanner.OnFound. It
|
||||||
// will be called with a pid and an offset. Observers are called concurrently.
|
// will be called with a pid and an offset. Observers are called concurrently.
|
||||||
// They have to be thread-safe.
|
// They have to be thread-safe.
|
||||||
@ -54,7 +58,7 @@ func New(symbol, pathglob string) *Scanner {
|
|||||||
pathglob: pathglob,
|
pathglob: pathglob,
|
||||||
cache: map[string]uint64{},
|
cache: map[string]uint64{},
|
||||||
|
|
||||||
Logger: log.New(os.Stderr, "[symbolyze] ", log.Ltime|log.Lmicroseconds),
|
logger: log.New(os.Stderr, "[symbolyze] ", log.Ltime|log.Lmicroseconds),
|
||||||
|
|
||||||
// debugging is off per default.
|
// debugging is off per default.
|
||||||
debugf: func(string, ...interface{}) {},
|
debugf: func(string, ...interface{}) {},
|
||||||
|
Loading…
Reference in New Issue
Block a user