newrelic
Version:
New Relic agent
57 lines (52 loc) • 1.24 kB
JavaScript
/*
* Copyright 2025 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
'use strict'
module.exports = severityToString
const SEV_UNKNOWN = 'unknown'
const SEV_TRACE = 'trace'
const SEV_DEBUG = 'debug'
const SEV_INFO = 'info'
const SEV_WARN = 'warn'
const SEV_ERROR = 'error'
const SEV_FATAL = 'fatal'
const severityMap = new Map([
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
])
/**
* Converts the OTEL severity number to a recognizable string.
*
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/c041658/specification/logs/data-model.md?plain=1#L292-L299
*
* @param {number} severityNumber The number to convert.
*
* @returns {string} The known string.
*/
function severityToString(severityNumber) {
return severityMap.get(severityNumber) ?? SEV_UNKNOWN
}