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
2c724e0a
Unverified
Commit
2c724e0a
authored
Nov 11, 2020
by
Valentin Agachi
Committed by
GitHub
Nov 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explore: support ANSI colors in live logs (#28895)
Closes #28893 Co-authored-by: Ivana <ivana.huckova@gmail.com>
parent
e834ad00
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
5 deletions
+41
-5
packages/grafana-ui/src/components/index.ts
+1
-0
public/app/features/explore/LiveLogs.test.tsx
+38
-3
public/app/features/explore/LiveLogs.tsx
+2
-2
No files found.
packages/grafana-ui/src/components/index.ts
View file @
2c724e0a
...
...
@@ -96,6 +96,7 @@ export { GraphSeriesToggler, GraphSeriesTogglerAPI } from './Graph/GraphSeriesTo
export
{
Collapse
,
ControlledCollapse
}
from
'./Collapse/Collapse'
;
export
{
CollapsableSection
}
from
'./Collapse/CollapsableSection'
;
export
{
LogLabels
}
from
'./Logs/LogLabels'
;
export
{
LogMessageAnsi
}
from
'./Logs/LogMessageAnsi'
;
export
{
LogRows
}
from
'./Logs/LogRows'
;
export
{
getLogRowStyles
}
from
'./Logs/getLogRowStyles'
;
export
{
ToggleButtonGroup
,
ToggleButton
}
from
'./ToggleButtonGroup/ToggleButtonGroup'
;
...
...
public/app/features/explore/LiveLogs.test.tsx
View file @
2c724e0a
...
...
@@ -55,10 +55,45 @@ describe('LiveLogs', () => {
expect
(
wrapper
.
contains
(
'log message 5'
)).
toBeTruthy
();
expect
(
wrapper
.
contains
(
'log message 6'
)).
toBeTruthy
();
});
it
(
'renders ansi logs'
,
()
=>
{
const
rows
:
LogRowModel
[]
=
[
makeLog
({
uid
:
'1'
}),
makeLog
({
hasAnsi
:
true
,
raw
:
'log message
\
u001B[31m2
\
u001B[0m'
,
uid
:
'2'
}),
makeLog
({
hasAnsi
:
true
,
raw
:
'log message
\
u001B[31m3
\
u001B[0m'
,
uid
:
'3'
}),
];
const
wrapper
=
mount
(
<
LiveLogsWithTheme
logRows=
{
rows
}
timeZone=
{
'utc'
}
stopLive=
{
()
=>
{}
}
onPause=
{
()
=>
{}
}
onResume=
{
()
=>
{}
}
isPaused=
{
true
}
/>
);
expect
(
wrapper
.
contains
(
'log message 1'
)).
toBeTruthy
();
expect
(
wrapper
.
contains
(
'log message 2'
)).
not
.
toBeTruthy
();
expect
(
wrapper
.
contains
(
'log message 3'
)).
not
.
toBeTruthy
();
expect
(
wrapper
.
find
(
'LogMessageAnsi'
)).
toHaveLength
(
2
);
expect
(
wrapper
.
find
(
'LogMessageAnsi'
)
.
first
()
.
prop
(
'value'
)
).
toBe
(
'log message
\
u001B[31m2
\
u001B[0m'
);
expect
(
wrapper
.
find
(
'LogMessageAnsi'
)
.
last
()
.
prop
(
'value'
)
).
toBe
(
'log message
\
u001B[31m3
\
u001B[0m'
);
});
});
const
makeLog
=
(
overides
:
Partial
<
LogRowModel
>
):
LogRowModel
=>
{
const
uid
=
overides
.
uid
||
'1'
;
const
makeLog
=
(
over
r
ides
:
Partial
<
LogRowModel
>
):
LogRowModel
=>
{
const
uid
=
over
r
ides
.
uid
||
'1'
;
const
entry
=
`log message
${
uid
}
`
;
return
{
uid
,
...
...
@@ -75,6 +110,6 @@ const makeLog = (overides: Partial<LogRowModel>): LogRowModel => {
timeEpochNs
:
'1000000'
,
timeLocal
:
''
,
timeUtc
:
''
,
...
overides
,
...
over
r
ides
,
};
};
public/app/features/explore/LiveLogs.tsx
View file @
2c724e0a
...
...
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import
{
css
,
cx
}
from
'emotion'
;
import
tinycolor
from
'tinycolor2'
;
import
{
Themeable
,
withTheme
,
getLogRowStyles
,
Icon
}
from
'@grafana/ui'
;
import
{
LogMessageAnsi
,
Themeable
,
withTheme
,
getLogRowStyles
,
Icon
}
from
'@grafana/ui'
;
import
{
GrafanaTheme
,
LogRowModel
,
TimeZone
,
dateTimeFormat
}
from
'@grafana/data'
;
import
{
ElapsedTime
}
from
'./ElapsedTime'
;
...
...
@@ -151,7 +151,7 @@ class LiveLogs extends PureComponent<Props, State> {
return
(
<
tr
className=
{
cx
(
logsRow
,
styles
.
logsRowFade
)
}
key=
{
row
.
uid
}
>
<
td
className=
{
cx
(
logsRowLocalTime
)
}
>
{
dateTimeFormat
(
row
.
timeEpochMs
,
{
timeZone
})
}
</
td
>
<
td
className=
{
cx
(
logsRowMessage
)
}
>
{
row
.
entry
}
</
td
>
<
td
className=
{
cx
(
logsRowMessage
)
}
>
{
row
.
hasAnsi
?
<
LogMessageAnsi
value=
{
row
.
raw
}
/>
:
row
.
entry
}
</
td
>
</
tr
>
);
})
}
...
...
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