apex / log

Structured logging package for Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting nil pointer references when log.SetHandler(...) is not set

matthewmueller opened this issue · comments

Is there anyway to prevent this? I'd love to use this library more like debug (logging within nested packages), seems like the default should be discard.

Definitely down to open a PR with a bit of direction :-)

Looks like this:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1d053c]

goroutine 5 [running]:
panic(0x283620, 0xc42000c0d0)
	/usr/local/Cellar/go/1.7.4_1/libexec/src/runtime/panic.go:500 +0x1a1
testing.tRunner.func1(0xc420094180)
	/usr/local/Cellar/go/1.7.4_1/libexec/src/testing/testing.go:579 +0x25d
panic(0x283620, 0xc42000c0d0)
	/usr/local/Cellar/go/1.7.4_1/libexec/src/runtime/panic.go:458 +0x243
github.com/apex/log.(*Logger).log(0xc420010200, 0x1, 0xc420105988, 0xc420018be0, 0x9e)
	/Users/matt/go/src/github.com/apex/log/logger.go:125 +0x6c
github.com/apex/log.(*Entry).Info(0xc420105988, 0xc420018be0, 0x9e)
	/Users/matt/go/src/github.com/apex/log/entry.go:61 +0x50
github.com/apex/log.(*Logger).Info(0xc420010200, 0xc420018be0, 0x9e)
	/Users/matt/go/src/github.com/apex/log/logger.go:68 +0x7f
github.com/apex/log.Info(0xc420018be0, 0x9e)
	/Users/matt/go/src/github.com/apex/log/pkg.go:44 +0x49

hmm you miiiight have to go get -u github.com/apex/log to grab the recent stuff, it should have a default stdlib log handler by default

yep, that did the trick – sorry for the false alarm!