-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional error handling (and optional debug file logging) (#639)
Adds several additional logging capabilities. Panic is now caught, and logged. A handful of extra startup log lines have been added. Adds the capability to mirror debug to a file. This greatly helps when debugging on windows, as extracting structed json from a file is simpler than extracting from the event log. This is something of an early preview -- I'd rather enable this by default, we until we have a log rotation ability, it won't work. Lastly, this upgrades the go svc version
- Loading branch information
1 parent
071da9f
commit 7244492
Showing
7 changed files
with
138 additions
and
23 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
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
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
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,31 @@ | ||
// Package filetee provides a go-kit compatible log mirroring tool. | ||
package teelogger | ||
|
||
import ( | ||
"github.com/go-kit/kit/log" | ||
) | ||
|
||
type teeLogger struct { | ||
loggers []log.Logger | ||
} | ||
|
||
func New(loggers ...log.Logger) log.Logger { | ||
l := &teeLogger{ | ||
loggers: loggers, | ||
} | ||
|
||
return l | ||
} | ||
|
||
// Log will log to each logger. If any of them error, it will return a | ||
// random error. | ||
func (l *teeLogger) Log(keyvals ...interface{}) error { | ||
var randomErr error | ||
for _, logger := range l.loggers { | ||
if err := logger.Log(keyvals...); err != nil { | ||
randomErr = err | ||
} | ||
} | ||
|
||
return randomErr | ||
} |