Tim Vaillancourt 47d49c6b92
Add go mod (#935)
* Add a go.mod file

* run go mod vendor again

* Move to a well-supported ini file reader

* Remove GO111MODULE=off

* Use go 1.16

* Rename github.com/outbrain/golib -> github.com/openark/golib

* Remove *.go-e files

* Fix for `strconv.ParseInt: parsing "": invalid syntax` error

* Add test for '[osc]' section

Co-authored-by: Nate Wernimont <nate.wernimont@workiva.com>
2021-06-24 20:19:37 +02:00

55 lines
1.0 KiB
Go

package log
import (
"io"
)
//Handler writes logs to somewhere
type Handler interface {
Write(p []byte) (n int, err error)
Close() error
}
// StreamHandler writes logs to a specified io Writer, maybe stdout, stderr, etc...
type StreamHandler struct {
w io.Writer
}
// NewStreamHandler creates a StreamHandler
func NewStreamHandler(w io.Writer) (*StreamHandler, error) {
h := new(StreamHandler)
h.w = w
return h, nil
}
// Write implements Handler interface
func (h *StreamHandler) Write(b []byte) (n int, err error) {
return h.w.Write(b)
}
// Close implements Handler interface
func (h *StreamHandler) Close() error {
return nil
}
// NullHandler does nothing, it discards anything.
type NullHandler struct {
}
// NewNullHandler creates a NullHandler
func NewNullHandler() (*NullHandler, error) {
return new(NullHandler), nil
}
// // Write implements Handler interface
func (h *NullHandler) Write(b []byte) (n int, err error) {
return len(b), nil
}
// Close implements Handler interface
func (h *NullHandler) Close() error {
return nil
}