Permalink
Browse files

panic after logging a fatal message

Change-Id: Id8596cbd432417ebd0d65f52385abc6ceb9272e9
  • Loading branch information...
bluesalt committed Nov 30, 2012
1 parent 87a90e7 commit 0bec89c57a5fabd5f5b73ac82bd506415d0b17f8
Showing with 12 additions and 0 deletions.
  1. +1 −0 logger.go
  2. +10 −0 logger_test.go
  3. +1 −0 tagged_logger.go
View
@@ -48,6 +48,7 @@ func (l *BaseLogger) Log(level LogLevel, message string, data map[string]string)
func (l *BaseLogger) Fatal(message string) {
l.Log(LOG_FATAL, message, nil)
+ panic(message)
}
func (l *BaseLogger) Error(message string) {
View
@@ -60,3 +60,13 @@ func (s *LoggerSuite) TestCreatingDupLogger(c *C) {
logger2 := NewLogger("foobar")
c.Assert(logger1, Equals, logger2)
}
+
+func (s *LoggerSuite) TestPanic(c *C) {
+ logger := NewLogger("foobar")
+ c.Assert(func() { logger.Fatal("fail!") }, PanicMatches, "fail!")
+ c.Assert(func() { logger.Fatalf("fail!%s", "fail!") }, PanicMatches, "fail!fail!")
+
+ t := NewTaggedLogger(logger, map[string]string{"foo": "bar"})
+ c.Assert(func() { t.Fatal("panic") }, PanicMatches, "panic")
+ c.Assert(func() { t.Fatalf("panic!%s", "panic!") }, PanicMatches, "panic!panic!")
+}
View
@@ -40,6 +40,7 @@ func (l *TaggedLogger) Log(level LogLevel, message string, data map[string]strin
func (l *TaggedLogger) Fatal(message string) {
l.Log(LOG_FATAL, message, nil)
+ panic(message)
}
func (l *TaggedLogger) Error(message string) {

0 comments on commit 0bec89c

Please sign in to comment.