

Show HN: Simple logger and debugger for Go programs - apsdehal
https://github.com/apsdehal/go-logger

======
AYBABTME
Colorized output by default will make for messy logs that can't be used. Sure
you can turn it off (with an integer, why not a bool?), but that shouldn't be
something compiled in your program. Also there are no means to `printf`
strings from the logger.

Finally, there are already a plethora of loggers for Go. I'd recommend logrus
for structured logs:

[https://github.com/Sirupsen/logrus](https://github.com/Sirupsen/logrus)

Or glog otherwise.

And a note: a logger isn't a debugger. GDB is a debugger for Go, see
[https://golang.org/doc/gdb](https://golang.org/doc/gdb)

Sorry if I come across as heartless, it's nice to see new people coming to Go.
But I don't think this is novel or news worthy.

------
Queue29
A wise gopher would use Rob Pikes glog package instead
[https://github.com/golang/glog](https://github.com/golang/glog)

------
jacobkranz
I've been trying to find a small logger program for Go and haven't had time to
write my own. Looks great and may start using it :)

The one minor issue is there is a syntax error in the readme. Should be import
"github.com/apsdehal/go-logger", not "go get github.com/apsdehal/go-logger"

------
yourabi
This looks interesting - I'll take a closer look.

You might want to check out the logrus package - which I'm using and pretty
happy with.
[https://github.com/sirupsen/logrus](https://github.com/sirupsen/logrus)

Logrus lets you add structured k,v fields so you do have to mess around with
fmt and also has hooks to support things like sending logs to syslog or remote
exception handling services.

~~~
pbnjay
That's pretty interesting too, I'm going to play with it. Thanks!

I recently stumbled across the standard expvar package[1] which lets me debug
memory usage and annotated metrics. Similar concept from a different angle I
guess.

1\. [http://golang.org/pkg/expvar/](http://golang.org/pkg/expvar/)

------
NateDad
Does this only output to stdout? It would be useful if it took an io.Writer so
you could write to a file or something else, too.

------
NateDad
Btw, anyone interested in loggers should check out my log rolling package
gopkg.in/natefinch/lumberjack.v2

------
latch
It's a shame there's no basic interface in the go's log package.

------
2mur
package =/= repo name

Don't do that

~~~
jacobkranz
I'm still new to Go... why wouldn't you want to do that? What should the repo
name be?

~~~
ori_b
By convention, the package and repo name should be the same. In this case,
that means your repo should be called logger.

~~~
sanemat
Thanks.

