Null logger

959 views
Skip to first unread message

Archos

unread,
Jul 25, 2012, 7:48:11 PM7/25/12
to golan...@googlegroups.com
Is there any way to create a null logger which been valid for Windows too? I mean a logger that really doesn't writes
I'd thinked in to use os.DevNull but would be valid for Windows too?

    null, err := os.Open(os.DevNull)
    if err != nil {
        log.Fatal(err)
    }
    Log = log.New(null, "", 0)

Message has been deleted

minux

unread,
Jul 25, 2012, 8:03:00 PM7/25/12
to Archos, golan...@googlegroups.com
On Wed, Jul 25, 2012 at 4:48 PM, Archos <raul...@sent.com> wrote:
Is there any way to create a null logger which been valid for Windows too? I mean a logger that really doesn't writes
I'd thinked in to use os.DevNull but would be valid for Windows too?
os.DevNull is portable across all supported OSes (in fact, everything in the os pkg is portable
except explicitly noted)

on Windows, os.DevNull is "NUL".

Carlos Cobo

unread,
Jul 26, 2012, 7:17:57 AM7/26/12
to golan...@googlegroups.com
ioutil.Discard uses something like this:

Reply all
Reply to author
Forward
0 new messages