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
3c6a7a51
Unverified
Commit
3c6a7a51
authored
Mar 04, 2020
by
Emil Tullstedt
Committed by
GitHub
Mar 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Logs: Improve log level guess (#22094)
Fixes #22075
parent
5166073f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
packages/grafana-data/src/utils/logs.test.ts
+1
-0
packages/grafana-data/src/utils/logs.ts
+10
-5
No files found.
packages/grafana-data/src/utils/logs.test.ts
View file @
3c6a7a51
...
...
@@ -35,6 +35,7 @@ describe('getLoglevel()', () => {
it
(
'returns first log level found'
,
()
=>
{
expect
(
getLogLevel
(
'WARN this could be a debug message'
)).
toBe
(
LogLevel
.
warn
);
expect
(
getLogLevel
(
'WARN this is a non-critical message'
)).
toBe
(
LogLevel
.
warn
);
});
});
...
...
packages/grafana-data/src/utils/logs.ts
View file @
3c6a7a51
...
...
@@ -20,16 +20,21 @@ export function getLogLevel(line: string): LogLevel {
if
(
!
line
)
{
return
LogLevel
.
unknown
;
}
let
level
=
LogLevel
.
unknown
;
let
currentIndex
:
number
|
undefined
=
undefined
;
for
(
const
key
of
Object
.
keys
(
LogLevel
))
{
const
regexp
=
new
RegExp
(
`\\b
${
key
}
\\b`
,
'i'
);
if
(
regexp
.
test
(
line
))
{
const
level
=
(
LogLevel
as
any
)[
key
];
if
(
level
)
{
return
level
;
const
result
=
regexp
.
exec
(
line
);
if
(
result
)
{
if
(
currentIndex
===
undefined
||
result
.
index
<
currentIndex
)
{
level
=
(
LogLevel
as
any
)[
key
];
currentIndex
=
result
.
index
;
}
}
}
return
LogLevel
.
unknown
;
return
level
;
}
export
function
getLogLevelFromKey
(
key
:
string
):
LogLevel
{
...
...
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