Is the log package thread-safe?

2,418 views
Skip to first unread message

Kowshik Prakasam

unread,
Sep 13, 2012, 4:59:19 PM9/13/12
to golan...@googlegroups.com
Is the log package (http://golang.org/pkg/log) thread-safe?


-Kowshik

Jesse McNelis

unread,
Sep 13, 2012, 7:54:55 PM9/13/12
to Kowshik Prakasam, golan...@googlegroups.com
On Fri, Sep 14, 2012 at 6:59 AM, Kowshik Prakasam <kow...@gmail.com> wrote:
> Is the log package (http://golang.org/pkg/log) thread-safe?

It's not documented as such. But the code shows that the Logger is thread-safe
as long as the underlying io.Writer is thread-safe or it has exclusive
access to it.

--
=====================
http://jessta.id.au

Rob Pike

unread,
Sep 17, 2012, 1:19:38 PM9/17/12
to Jesse McNelis, Kowshik Prakasam, golan...@googlegroups.com
It is documented. Logger says:

A Logger can be used simultaneously from
// multiple goroutines; it guarantees to serialize access to the Writer.

-rob
Reply all
Reply to author
Forward
0 new messages