summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/logr/v2/targets/writer.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2021-10-16 23:11:32 +0200
committerWim <wim@42.be>2021-10-16 23:23:24 +0200
commit20f6c05ec50739d31f4dbe9fde0d223f2c43f6e8 (patch)
tree230edca06449a8d1755f08aabf45a03e07e6f17c /vendor/github.com/mattermost/logr/v2/targets/writer.go
parent57fce93af7f64f025cec6f3ed6088163086bc9fe (diff)
downloadmatterbridge-msglm-20f6c05ec50739d31f4dbe9fde0d223f2c43f6e8.tar.gz
matterbridge-msglm-20f6c05ec50739d31f4dbe9fde0d223f2c43f6e8.tar.bz2
matterbridge-msglm-20f6c05ec50739d31f4dbe9fde0d223f2c43f6e8.zip
Update vendor
Diffstat (limited to 'vendor/github.com/mattermost/logr/v2/targets/writer.go')
-rw-r--r--vendor/github.com/mattermost/logr/v2/targets/writer.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/github.com/mattermost/logr/v2/targets/writer.go b/vendor/github.com/mattermost/logr/v2/targets/writer.go
new file mode 100644
index 00000000..d9f64d76
--- /dev/null
+++ b/vendor/github.com/mattermost/logr/v2/targets/writer.go
@@ -0,0 +1,38 @@
+package targets
+
+import (
+ "io"
+ "io/ioutil"
+
+ "github.com/mattermost/logr/v2"
+)
+
+// Writer outputs log records to any `io.Writer`.
+type Writer struct {
+ out io.Writer
+}
+
+// NewWriterTarget creates a target capable of outputting log records to an io.Writer.
+func NewWriterTarget(out io.Writer) *Writer {
+ if out == nil {
+ out = ioutil.Discard
+ }
+ w := &Writer{out: out}
+ return w
+}
+
+// Init is called once to initialize the target.
+func (w *Writer) Init() error {
+ return nil
+}
+
+// Write outputs bytes to this file target.
+func (w *Writer) Write(p []byte, rec *logr.LogRec) (int, error) {
+ return w.out.Write(p)
+}
+
+// Shutdown is called once to free/close any resources.
+// Target queue is already drained when this is called.
+func (w *Writer) Shutdown() error {
+ return nil
+}