Commit f37814f3 by Ivana Huckova Committed by GitHub

Fix getLogLevelFromKey when non-string supplied (#23654)

parent 1f6a6b38
...@@ -46,6 +46,9 @@ describe('getLogLevelFromKey()', () => { ...@@ -46,6 +46,9 @@ describe('getLogLevelFromKey()', () => {
it('returns correct log level when level is capitalized', () => { it('returns correct log level when level is capitalized', () => {
expect(getLogLevelFromKey('INFO')).toBe(LogLevel.info); expect(getLogLevelFromKey('INFO')).toBe(LogLevel.info);
}); });
it('returns unknown log level when level is integer', () => {
expect(getLogLevelFromKey(1)).toBe(LogLevel.unknown);
});
}); });
describe('calculateLogsLabelStats()', () => { describe('calculateLogsLabelStats()', () => {
......
...@@ -37,8 +37,8 @@ export function getLogLevel(line: string): LogLevel { ...@@ -37,8 +37,8 @@ export function getLogLevel(line: string): LogLevel {
return level; return level;
} }
export function getLogLevelFromKey(key: string): LogLevel { export function getLogLevelFromKey(key: string | number): LogLevel {
const level = (LogLevel as any)[key.toLowerCase()]; const level = (LogLevel as any)[key.toString().toLowerCase()];
if (level) { if (level) {
return level; return level;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment