1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-28 21:09:17 +02:00
opentelemetry-go/log/global/log_test.go
Tyler Yahn 335f4de960
Add global log package (#5085)
* Add the log/global package

* Implement the stubbed features

* Add ConcurrentSafe tests

* Restructure with internal implementation

* Add internal global state

* Use internal state in log/global

* Add TestDelegation

* Fix lint

* Clean log_test.go

* Clean up

* Add changelog entry

* Simplify TestMultipleGlobalLoggerProvider

* Shorten log.go

* Fix comment text wrapping

* Shorten state_test.go

* Don't pollute output in TestSetLoggerProvider
2024-03-19 11:28:11 -07:00

25 lines
515 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package global // import "go.opentelemetry.io/otel/log/global"
import (
"testing"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/log/noop"
)
func TestMultipleGlobalLoggerProvider(t *testing.T) {
type provider struct{ log.LoggerProvider }
p1, p2 := provider{}, noop.NewLoggerProvider()
SetLoggerProvider(&p1)
SetLoggerProvider(p2)
assert.Equal(t, p2, GetLoggerProvider())
}