mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
chore(deps): bump github.com/spf13/viper from 1.16.0 to 1.18.2 (#4861)
* chore(deps): bump github.com/spf13/viper from 1.16.0 to 1.18.2 Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.16.0 to 1.18.2. - [Release notes](https://github.com/spf13/viper/releases) - [Commits](https://github.com/spf13/viper/compare/v1.16.0...v1.18.2) --- updated-dependencies: - dependency-name: github.com/spf13/viper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix race --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Caleb Doxsey <cdoxsey@pomerium.com>
This commit is contained in:
parent
07d608792f
commit
615c6257e6
7 changed files with 143 additions and 127 deletions
48
internal/log/multiwriter.go
Normal file
48
internal/log/multiwriter.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
package log
|
||||
|
||||
import (
|
||||
"io"
|
||||
"slices"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// A MultiWriter dispatches writes to multiple writers.
|
||||
type MultiWriter struct {
|
||||
mu sync.Mutex
|
||||
ws []io.Writer
|
||||
}
|
||||
|
||||
// NewMultiWriter creates a new MultiWriter
|
||||
func NewMultiWriter() *MultiWriter {
|
||||
return &MultiWriter{}
|
||||
}
|
||||
|
||||
// Add adds a writer to the multi writer.
|
||||
func (m *MultiWriter) Add(w io.Writer) {
|
||||
m.mu.Lock()
|
||||
m.ws = append(m.ws, w)
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
// Remove removes a writer from the multi writer.
|
||||
func (m *MultiWriter) Remove(w io.Writer) {
|
||||
m.mu.Lock()
|
||||
m.ws = slices.DeleteFunc(m.ws, func(mw io.Writer) bool {
|
||||
return mw == w
|
||||
})
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
// Write writes data to all the writers. The last count and error are returned.
|
||||
func (m *MultiWriter) Write(data []byte) (int, error) {
|
||||
var n int
|
||||
var err error
|
||||
|
||||
m.mu.Lock()
|
||||
for _, w := range m.ws {
|
||||
n, err = w.Write(data)
|
||||
}
|
||||
m.mu.Unlock()
|
||||
|
||||
return n, err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue