1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

Add SeverityUndefined to otel/log (#5072)

* Add SeverityUndefined

* Add changelog entry

---------

Co-authored-by: Sam Xie <sam@samxie.me>
This commit is contained in:
Tyler Yahn
2024-03-14 13:22:12 -07:00
committed by GitHub
parent ca35244789
commit 42c1708ed5
4 changed files with 15 additions and 4 deletions
+3
View File
@@ -13,6 +13,9 @@ type Severity int
// Severity values defined by OpenTelemetry.
const (
// SeverityUndefined represents an unset Severity.
SeverityUndefined Severity = 0 // UNDEFINED
// A fine-grained debugging log record. Typically disabled in default
// configurations.
SeverityTrace1 Severity = 1 // TRACE
+4 -4
View File
@@ -8,6 +8,7 @@ func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[SeverityUndefined-0]
_ = x[SeverityTrace1-1]
_ = x[SeverityTrace2-2]
_ = x[SeverityTrace3-3]
@@ -34,14 +35,13 @@ func _() {
_ = x[SeverityFatal4-24]
}
const _Severity_name = "TRACETRACE2TRACE3TRACE4DEBUGDEBUG2DEBUG3DEBUG4INFOINFO2INFO3INFO4WARNWARN2WARN3WARN4ERRORERROR2ERROR3ERROR4FATALFATAL2FATAL3FATAL4"
const _Severity_name = "UNDEFINEDTRACETRACE2TRACE3TRACE4DEBUGDEBUG2DEBUG3DEBUG4INFOINFO2INFO3INFO4WARNWARN2WARN3WARN4ERRORERROR2ERROR3ERROR4FATALFATAL2FATAL3FATAL4"
var _Severity_index = [...]uint8{0, 5, 11, 17, 23, 28, 34, 40, 46, 50, 55, 60, 65, 69, 74, 79, 84, 89, 95, 101, 107, 112, 118, 124, 130}
var _Severity_index = [...]uint8{0, 9, 14, 20, 26, 32, 37, 43, 49, 55, 59, 64, 69, 74, 78, 83, 88, 93, 98, 104, 110, 116, 121, 127, 133, 139}
func (i Severity) String() string {
i -= 1
if i < 0 || i >= Severity(len(_Severity_index)-1) {
return "Severity(" + strconv.FormatInt(int64(i+1), 10) + ")"
return "Severity(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Severity_name[_Severity_index[i]:_Severity_index[i+1]]
}
+6
View File
@@ -19,6 +19,12 @@ func TestSeverity(t *testing.T) {
value int
str string
}{
{
name: "SeverityUndefined",
severity: log.SeverityUndefined,
value: 0,
str: "UNDEFINED",
},
{
name: "SeverityTrace",
severity: log.SeverityTrace,