forked from nanomsg/mangos-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #252 Add logging to ease debugging connection reattempts
- Loading branch information
Ben Krieger
committed
Nov 27, 2016
1 parent
74b6487
commit 49c2090
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package mangos | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"sync" | ||
) | ||
|
||
type logger struct { | ||
sync.Mutex | ||
buf bytes.Buffer | ||
} | ||
|
||
func (l *logger) Log(a ...interface{}) { | ||
l.Lock() | ||
defer l.Unlock() | ||
l.buf.WriteString(fmt.Sprint(a...)) | ||
l.buf.WriteByte('\n') | ||
} | ||
|
||
func (l *logger) Logf(format string, a ...interface{}) { | ||
l.Lock() | ||
defer l.Unlock() | ||
l.buf.WriteString(fmt.Sprintf(format, a...)) | ||
l.buf.WriteByte('\n') | ||
} | ||
|
||
func (l *logger) String() string { | ||
l.Lock() | ||
defer l.Unlock() | ||
return l.buf.String() | ||
} | ||
|
||
func (l *logger) Clear() { | ||
l.Lock() | ||
defer l.Unlock() | ||
l.buf.Reset() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters