forked from maruel/subcommands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.go
31 lines (25 loc) · 821 Bytes
/
logger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2012 Marc-Antoine Ruel. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
package subcommands
import (
"io"
"log"
)
// PanicWriter is an io.Writer that will panic if used.
type PanicWriter struct {
}
// Write implements io.Writer.
func (p PanicWriter) Write(b []byte) (n int, err error) {
panic("unexpected write")
}
// KillStdLog sets an output that will panic if used. This permits trapping any
// log.*() calls that would inhibit efficient use of t.Parallel().
func KillStdLog() {
log.SetOutput(PanicWriter{})
}
// VoidStdLog sets an output that will be ignored. This permits ignoring any
// log.*() calls that would inhibit efficient use of t.Parallel().
func VoidStdLog() {
log.SetOutput(io.Discard)
}