Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
6feb4a32
Unverified
Commit
6feb4a32
authored
Jan 21, 2020
by
Ivana Huckova
Committed by
GitHub
Jan 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explore: Fix log level color and add tests (#21646)
parent
92ef8644
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletions
+15
-1
packages/grafana-data/src/utils/logs.test.ts
+14
-0
packages/grafana-data/src/utils/logs.ts
+1
-1
No files found.
packages/grafana-data/src/utils/logs.test.ts
View file @
6feb4a32
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
getParser
,
getParser
,
LogsParsers
,
LogsParsers
,
calculateStats
,
calculateStats
,
getLogLevelFromKey
,
}
from
'./logs'
;
}
from
'./logs'
;
describe
(
'getLoglevel()'
,
()
=>
{
describe
(
'getLoglevel()'
,
()
=>
{
...
@@ -23,6 +24,10 @@ describe('getLoglevel()', () => {
...
@@ -23,6 +24,10 @@ describe('getLoglevel()', () => {
expect
(
getLogLevel
(
'[Warn]'
)).
toBe
(
'warning'
);
expect
(
getLogLevel
(
'[Warn]'
)).
toBe
(
'warning'
);
});
});
it
(
'returns correct log level when level is capitalized'
,
()
=>
{
expect
(
getLogLevel
(
'WARN'
)).
toBe
(
LogLevel
.
warn
);
});
it
(
'returns log level on line contains a log level'
,
()
=>
{
it
(
'returns log level on line contains a log level'
,
()
=>
{
expect
(
getLogLevel
(
'warn: it is looking bad'
)).
toBe
(
LogLevel
.
warn
);
expect
(
getLogLevel
(
'warn: it is looking bad'
)).
toBe
(
LogLevel
.
warn
);
expect
(
getLogLevel
(
'2007-12-12 12:12:12 [WARN]: it is looking bad'
)).
toBe
(
LogLevel
.
warn
);
expect
(
getLogLevel
(
'2007-12-12 12:12:12 [WARN]: it is looking bad'
)).
toBe
(
LogLevel
.
warn
);
...
@@ -33,6 +38,15 @@ describe('getLoglevel()', () => {
...
@@ -33,6 +38,15 @@ describe('getLoglevel()', () => {
});
});
});
});
describe
(
'getLogLevelFromKey()'
,
()
=>
{
it
(
'returns correct log level'
,
()
=>
{
expect
(
getLogLevelFromKey
(
'info'
)).
toBe
(
LogLevel
.
info
);
});
it
(
'returns correct log level when level is capitalized'
,
()
=>
{
expect
(
getLogLevelFromKey
(
'INFO'
)).
toBe
(
LogLevel
.
info
);
});
});
describe
(
'calculateLogsLabelStats()'
,
()
=>
{
describe
(
'calculateLogsLabelStats()'
,
()
=>
{
test
(
'should return no stats for empty rows'
,
()
=>
{
test
(
'should return no stats for empty rows'
,
()
=>
{
expect
(
calculateLogsLabelStats
([],
''
)).
toEqual
([]);
expect
(
calculateLogsLabelStats
([],
''
)).
toEqual
([]);
...
...
packages/grafana-data/src/utils/logs.ts
View file @
6feb4a32
...
@@ -33,7 +33,7 @@ export function getLogLevel(line: string): LogLevel {
...
@@ -33,7 +33,7 @@ export function getLogLevel(line: string): LogLevel {
}
}
export
function
getLogLevelFromKey
(
key
:
string
):
LogLevel
{
export
function
getLogLevelFromKey
(
key
:
string
):
LogLevel
{
const
level
=
(
LogLevel
as
any
)[
key
];
const
level
=
(
LogLevel
as
any
)[
key
.
toLowerCase
()
];
if
(
level
)
{
if
(
level
)
{
return
level
;
return
level
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment