From 2570ecd2acf12aac73a199f1415e0196f6fe1d97 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sat, 10 Aug 2013 20:07:37 -0500 Subject: [PATCH] Move log closure code into its own file. --- logclosure.go | 21 +++++++++++++++++++++ peer.go | 16 ---------------- 2 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 logclosure.go diff --git a/logclosure.go b/logclosure.go new file mode 100644 index 00000000..7763357d --- /dev/null +++ b/logclosure.go @@ -0,0 +1,21 @@ +// Copyright (c) 2013 Conformal Systems LLC. +// Use of this source code is governed by an ISC +// license that can be found in the LICENSE file. + +package main + +// logClosure is used to provide a closure over expensive logging operations +// so don't have to be performed when the logging level doesn't warrant it. +type logClosure func() string + +// String invokes the underlying function and returns the result. +func (c logClosure) String() string { + return c() +} + +// newLogClosure returns a new closure over a function that returns a string +// which itself provides a Stringer interface so that it can be used with the +// logging system. +func newLogClosure(c func() string) logClosure { + return logClosure(c) +} diff --git a/peer.go b/peer.go index 0fdbf3bb..47f521cf 100644 --- a/peer.go +++ b/peer.go @@ -787,19 +787,3 @@ func newPeer(s *server, conn net.Conn, inbound bool, persistent bool) *peer { } return &p } - -// logClosure is used to provide a closure over expensive logging operations -// so don't have to be performed when the logging level doesn't warrant it. -type logClosure func() string - -// String invokes the underlying function and returns the result. -func (c logClosure) String() string { - return c() -} - -// newLogClosure returns a new closure over a function that returns a string -// which itself provides a Stringer interface so that it can be used with the -// logging system. -func newLogClosure(c func() string) logClosure { - return logClosure(c) -}