| 1 | // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> |
| 2 | // SPDX-License-Identifier: MIT |
| 3 | |
| 4 | package logging_testscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/ |
| 5 | |
| 6 | import ( |
| 7 | "bytesscip-go gomod github.com/golang/go/src go1.20 bytes/" |
| 8 | "osscip-go gomod github.com/golang/go/src go1.20 os/" |
| 9 | "stringsscip-go gomod github.com/golang/go/src go1.20 strings/" |
| 10 | "testingscip-go gomod github.com/golang/go/src go1.20 testing/" |
| 11 | |
| 12 | "github.com/pion/loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/" |
| 13 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/" |
| 14 | ) |
| 15 | |
| 16 | func testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#, logger *loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) { |
| 17 | t.Helperscip-go gomod github.com/golang/go/src go1.20 testing/common#Helper().() |
| 18 | |
| 19 | var outBuf bytesscip-go gomod github.com/golang/go/src go1.20 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer# |
| 20 | logger.WithOutputscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#WithOutput().(&outBuf) |
| 21 | |
| 22 | logger.Debugscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Debug().("this shouldn't be logged") |
| 23 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.GreaterOrEqualscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/GreaterOrEqual().(t, 0, outBuf.Lenscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#Len().(), "Debug was logged when it shouldn't have been") |
| 24 | |
| 25 | logger.Debugfscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Debugf().("this shouldn't be logged") |
| 26 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.GreaterOrEqualscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/GreaterOrEqual().(t, 0, outBuf.Lenscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#Len().(), "Debug was logged when it shouldn't have been") |
| 27 | } |
| 28 | |
| 29 | func testDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testDebugLevel().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#, logger *loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) { |
| 30 | t.Helperscip-go gomod github.com/golang/go/src go1.20 testing/common#Helper().() |
| 31 | |
| 32 | var outBuf bytesscip-go gomod github.com/golang/go/src go1.20 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer# |
| 33 | logger.WithOutputscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#WithOutput().(&outBuf) |
| 34 | |
| 35 | dbgMsg := "this is a debug message" |
| 36 | logger.Debugscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Debug().(dbgMsg) |
| 37 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), dbgMsg), |
| 38 | "Expected to find %q in %q, but didn't", dbgMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 39 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), dbgMsg), |
| 40 | "Expected to find %q in %q, but didn't", dbgMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 41 | |
| 42 | logger.Debugfscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Debugf().(dbgMsg) // nolint: govet |
| 43 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), dbgMsg), |
| 44 | "Expected to find %q in %q, but didn't", dbgMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 45 | } |
| 46 | |
| 47 | func testWarnLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testWarnLevel().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#, logger *loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) { |
| 48 | t.Helperscip-go gomod github.com/golang/go/src go1.20 testing/common#Helper().() |
| 49 | |
| 50 | var outBuf bytesscip-go gomod github.com/golang/go/src go1.20 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer# |
| 51 | logger.WithOutputscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#WithOutput().(&outBuf) |
| 52 | |
| 53 | warnMsg := "this is a warning message" |
| 54 | logger.Warnscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Warn().(warnMsg) |
| 55 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), warnMsg), |
| 56 | "Expected to find %q in %q, but didn't", warnMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 57 | |
| 58 | logger.Warnfscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Warnf().(warnMsg) // nolint: govet |
| 59 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), warnMsg), |
| 60 | "Expected to find %q in %q, but didn't", warnMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 61 | } |
| 62 | |
| 63 | func testErrorLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testErrorLevel().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#, logger *loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) { |
| 64 | t.Helperscip-go gomod github.com/golang/go/src go1.20 testing/common#Helper().() |
| 65 | |
| 66 | var outBuf bytesscip-go gomod github.com/golang/go/src go1.20 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer# |
| 67 | logger.WithOutputscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#WithOutput().(&outBuf) |
| 68 | |
| 69 | errMsg := "this is an error message" |
| 70 | logger.Errorscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Error().(errMsg) |
| 71 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), errMsg), |
| 72 | "Expected to find %q in %q but didn't", errMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 73 | |
| 74 | logger.Errorfscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Errorf().(errMsg) // nolint: govet |
| 75 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), errMsg), |
| 76 | "Expected to find %q in %q but didn't", errMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 77 | } |
| 78 | |
| 79 | func testTraceLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testTraceLevel().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#, logger *loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) { |
| 80 | t.Helperscip-go gomod github.com/golang/go/src go1.20 testing/common#Helper().() |
| 81 | |
| 82 | var outBuf bytesscip-go gomod github.com/golang/go/src go1.20 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer# |
| 83 | logger.WithOutputscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#WithOutput().(&outBuf) |
| 84 | |
| 85 | traceMsg := "trace message" |
| 86 | logger.Tracescip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Trace().(traceMsg) |
| 87 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), traceMsg), |
| 88 | "Expected to find %q in %q but didn't", traceMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 89 | |
| 90 | logger.Tracefscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Tracef().(traceMsg) // nolint: govet |
| 91 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), traceMsg), |
| 92 | "Expected to find %q in %q but didn't", traceMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 93 | } |
| 94 | |
| 95 | func testInfoLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testInfoLevel().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#, logger *loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) { |
| 96 | t.Helperscip-go gomod github.com/golang/go/src go1.20 testing/common#Helper().() |
| 97 | |
| 98 | var outBuf bytesscip-go gomod github.com/golang/go/src go1.20 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer# |
| 99 | logger.WithOutputscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#WithOutput().(&outBuf) |
| 100 | |
| 101 | infoMsg := "info message" |
| 102 | logger.Infoscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Info().(infoMsg) |
| 103 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), infoMsg), |
| 104 | "Expected to find %q in %q but didn't", infoMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 105 | |
| 106 | logger.Infofscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#Infof().(infoMsg) // nolint: govet |
| 107 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truefscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Truef().(t, stringsscip-go gomod github.com/golang/go/src go1.20 strings/.Containsscip-go gomod github.com/golang/go/src go1.20 strings/Contains().(outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().(), infoMsg), |
| 108 | "Expected to find %q in %q but didn't", infoMsg, outBuf.Stringscip-go gomod github.com/golang/go/src go1.20 bytes/Buffer#String().()) |
| 109 | } |
| 110 | |
| 111 | func testAllLevelsscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testAllLevels().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#, logger *loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) { |
| 112 | t.Helperscip-go gomod github.com/golang/go/src go1.20 testing/common#Helper().() |
| 113 | |
| 114 | testDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testDebugLevel().(t, logger) |
| 115 | testWarnLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testWarnLevel().(t, logger) |
| 116 | testErrorLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testErrorLevel().(t, logger) |
| 117 | testTraceLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testTraceLevel().(t, logger) |
| 118 | testInfoLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testInfoLevel().(t, logger) |
| 119 | } |
| 120 | |
| 121 | func TestDefaultLoggerFactoryscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/TestDefaultLoggerFactory().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 122 | factory := loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLoggerFactoryscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#{ |
| 123 | Writerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#Writer.: osscip-go gomod github.com/golang/go/src go1.20 os/.Stderrscip-go gomod github.com/golang/go/src go1.20 os/Stderr., |
| 124 | DefaultLogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#DefaultLogLevel.: loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelWarnscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelWarn., |
| 125 | ScopeLevelsscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#ScopeLevels.: map[string]loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#{ |
| 126 | "foo": loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelDebugscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelDebug., |
| 127 | }, |
| 128 | } |
| 129 | |
| 130 | logger := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("baz") |
| 131 | bazLogger, ok := logger.(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 132 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Invalid logger type") |
| 133 | |
| 134 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, bazLogger) |
| 135 | testWarnLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testWarnLevel().(t, bazLogger) |
| 136 | |
| 137 | logger = factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("foo") |
| 138 | fooLogger, ok := logger.(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 139 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Invalid logger type") |
| 140 | |
| 141 | testDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testDebugLevel().(t, fooLogger) |
| 142 | } |
| 143 | |
| 144 | func TestDefaultLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/TestDefaultLogger().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 145 | logger := loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/. |
| 146 | NewDefaultLeveledLoggerForScopescip-go gomod github.com/pion/logging . `github.com/pion/logging`/NewDefaultLeveledLoggerForScope().("test1", loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelWarnscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelWarn., osscip-go gomod github.com/golang/go/src go1.20 os/.Stderrscip-go gomod github.com/golang/go/src go1.20 os/Stderr.) |
| 147 | |
| 148 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, logger) |
| 149 | testWarnLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testWarnLevel().(t, logger) |
| 150 | testErrorLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testErrorLevel().(t, logger) |
| 151 | } |
| 152 | |
| 153 | func TestNewDefaultLoggerFactoryscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/TestNewDefaultLoggerFactory().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 154 | factory := loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.NewDefaultLoggerFactoryscip-go gomod github.com/pion/logging . `github.com/pion/logging`/NewDefaultLoggerFactory().() |
| 155 | |
| 156 | disabled := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("DISABLE") |
| 157 | errorLevel := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("ERROR") |
| 158 | warnLevel := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("WARN") |
| 159 | infoLevel := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("INFO") |
| 160 | debugLevel := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("DEBUG") |
| 161 | traceLevel := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("TRACE") |
| 162 | |
| 163 | disabledLogger, ok := disabled.(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 164 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Missing disabled logger") |
| 165 | |
| 166 | errorLogger, ok := errorLevel.(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 167 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Missing error logger") |
| 168 | |
| 169 | warnLogger, ok := warnLevel.(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 170 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Missing warn logger") |
| 171 | |
| 172 | infoLogger, ok := infoLevel.(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 173 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Missing info logger") |
| 174 | |
| 175 | debugLogger, ok := debugLevel.(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 176 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Missing debug logger") |
| 177 | |
| 178 | traceLogger, ok := traceLevel.(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 179 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Missing trace logger") |
| 180 | |
| 181 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, disabledLogger) |
| 182 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, errorLogger) |
| 183 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, warnLogger) |
| 184 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, infoLogger) |
| 185 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, debugLogger) |
| 186 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, traceLogger) |
| 187 | } |
| 188 | |
| 189 | func TestNewDefaultLoggerFactoryLogAllscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/TestNewDefaultLoggerFactoryLogAll().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 190 | t.Setenvscip-go gomod github.com/golang/go/src go1.20 testing/T#Setenv().("PION_LOG_ERROR", "all") |
| 191 | t.Setenvscip-go gomod github.com/golang/go/src go1.20 testing/T#Setenv().("PION_LOG_WARN", "all") |
| 192 | t.Setenvscip-go gomod github.com/golang/go/src go1.20 testing/T#Setenv().("PION_LOG_INFO", "all") |
| 193 | t.Setenvscip-go gomod github.com/golang/go/src go1.20 testing/T#Setenv().("PION_LOG_DEBUG", "all") |
| 194 | t.Setenvscip-go gomod github.com/golang/go/src go1.20 testing/T#Setenv().("PION_LOG_TRACE", "all") |
| 195 | |
| 196 | factory := loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.NewDefaultLoggerFactoryscip-go gomod github.com/pion/logging . `github.com/pion/logging`/NewDefaultLoggerFactory().() |
| 197 | |
| 198 | testAPI, ok := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("test").(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 199 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Invalid logger factory type") |
| 200 | |
| 201 | testAllLevelsscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testAllLevels().(t, testAPI) |
| 202 | } |
| 203 | |
| 204 | func TestNewDefaultLoggerFactorySpecifcScopesscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/TestNewDefaultLoggerFactorySpecifcScopes().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 205 | t.Setenvscip-go gomod github.com/golang/go/src go1.20 testing/T#Setenv().("PION_LOG_DEBUG", "feature,rtp-logger") |
| 206 | |
| 207 | factory := loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.NewDefaultLoggerFactoryscip-go gomod github.com/pion/logging . `github.com/pion/logging`/NewDefaultLoggerFactory().() |
| 208 | |
| 209 | feature, ok := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("feature").(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 210 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Invalid logger factory type") |
| 211 | |
| 212 | rtp, ok := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("rtp-logger").(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 213 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Invalid logger factory type") |
| 214 | |
| 215 | noScope, ok := factory.NewLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("no-scope").(*loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.DefaultLeveledLoggerscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#) |
| 216 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/True().(t, ok, "Invalid logger factory type") |
| 217 | |
| 218 | testDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testDebugLevel().(t, feature) |
| 219 | testDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testDebugLevel().(t, rtp) |
| 220 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, noScope) |
| 221 | } |
| 222 | |
| 223 | func TestSetLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/TestSetLevel().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 224 | logger := loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/. |
| 225 | NewDefaultLeveledLoggerForScopescip-go gomod github.com/pion/logging . `github.com/pion/logging`/NewDefaultLeveledLoggerForScope().("testSetLevel", loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelWarnscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelWarn., osscip-go gomod github.com/golang/go/src go1.20 os/.Stderrscip-go gomod github.com/golang/go/src go1.20 os/Stderr.) |
| 226 | |
| 227 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, logger) |
| 228 | logger.SetLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/DefaultLeveledLogger#SetLevel().(loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelDebugscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelDebug.) |
| 229 | testDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testDebugLevel().(t, logger) |
| 230 | } |
| 231 | |
| 232 | func TestLogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/TestLogLevel().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 233 | logLevel := loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelDisabledscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelDisabled. |
| 234 | |
| 235 | logLevel.Setscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#Set().(loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelErrorscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelError.) |
| 236 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Equal().(t, loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelErrorscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelError., logLevel.Getscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#Get().(), "LogLevel was not set to LogLevelError") |
| 237 | } |
| 238 | |
| 239 | func TestLogLevelStringscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/TestLogLevelString().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 240 | expected := map[loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#]string{ |
| 241 | loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelDisabledscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelDisabled.: "Disabled", |
| 242 | loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelErrorscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelError.: "Error", |
| 243 | loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelWarnscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelWarn.: "Warn", |
| 244 | loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelInfoscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelInfo.: "Info", |
| 245 | loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelDebugscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelDebug.: "Debug", |
| 246 | loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelTracescip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelTrace.: "Trace", |
| 247 | loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#(999): "UNKNOWN", |
| 248 | } |
| 249 | |
| 250 | for level, expectedStr := range expected { |
| 251 | assertscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.10.0 `github.com/stretchr/testify/assert`/Equal().(t, expectedStr, level.Stringscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevel#String().()) |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | func TestNewDefaultLoggerStderrscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/TestNewDefaultLoggerStderr().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) { |
| 256 | logger := loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.NewDefaultLeveledLoggerForScopescip-go gomod github.com/pion/logging . `github.com/pion/logging`/NewDefaultLeveledLoggerForScope().("test", loggingscip-go gomod github.com/pion/logging . `github.com/pion/logging`/.LogLevelWarnscip-go gomod github.com/pion/logging . `github.com/pion/logging`/LogLevelWarn., nil) |
| 257 | |
| 258 | testNoDebugLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testNoDebugLevel().(t, logger) |
| 259 | testWarnLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testWarnLevel().(t, logger) |
| 260 | testErrorLevelscip-go gomod github.com/pion/logging . `github.com/pion/logging_test`/testErrorLevel().(t, logger) |
| 261 | } |