first stab at getting nice json output in the logs

This commit is contained in:
Iuri Matias 2018-10-14 20:40:19 -04:00 committed by Pascal Precht
parent 639ede7b77
commit b126871a95
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
4 changed files with 65 additions and 3 deletions

View File

@ -3929,6 +3929,14 @@
"bser": "^2.0.0"
}
},
"fbemitter": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/fbemitter/-/fbemitter-2.1.1.tgz",
"integrity": "sha1-Uj4U/a9SSIBbsC9i78M75wP1GGU=",
"requires": {
"fbjs": "^0.8.4"
}
},
"fbjs": {
"version": "0.8.17",
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz",
@ -4072,6 +4080,15 @@
"resolved": "https://registry.npmjs.org/flatten/-/flatten-1.0.2.tgz",
"integrity": "sha1-2uRqnXj74lKSJYzB54CkHZXAN4I="
},
"flux": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/flux/-/flux-3.1.3.tgz",
"integrity": "sha1-0jvtUVp5oi2TOrU6tK2hnQWy8Io=",
"requires": {
"fbemitter": "^2.0.0",
"fbjs": "^0.8.0"
}
},
"follow-redirects": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.1.tgz",
@ -9691,6 +9708,30 @@
"react-base16-styling": "^0.5.1"
}
},
"react-json-view": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/react-json-view/-/react-json-view-1.19.1.tgz",
"integrity": "sha512-u5e0XDLIs9Rj43vWkKvwL8G3JzvXSl6etuS5G42a8klMohZuYFQzSN6ri+/GiBptDqlrXPTdExJVU7x9rrlXhg==",
"requires": {
"flux": "^3.1.3",
"react-base16-styling": "^0.6.0",
"react-lifecycles-compat": "^3.0.4",
"react-textarea-autosize": "^6.1.0"
},
"dependencies": {
"react-base16-styling": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/react-base16-styling/-/react-base16-styling-0.6.0.tgz",
"integrity": "sha1-7yFW1mz0E5aVyKFniGy2nqZgeSw=",
"requires": {
"base16": "^1.0.0",
"lodash.curry": "^4.0.1",
"lodash.flow": "^3.3.0",
"pure-color": "^1.2.0"
}
}
}
},
"react-lifecycles-compat": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
@ -9817,6 +9858,14 @@
"prop-types": "^15.5.6"
}
},
"react-textarea-autosize": {
"version": "6.1.0",
"resolved": "http://registry.npmjs.org/react-textarea-autosize/-/react-textarea-autosize-6.1.0.tgz",
"integrity": "sha512-F6bI1dgib6fSvG8so1HuArPUv+iVEfPliuLWusLF+gAKz0FbB4jLrWUrTAeq1afnPT2c9toEZYUdz/y1uKMy4A==",
"requires": {
"prop-types": "^15.6.0"
}
},
"react-transition-group": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.4.0.tgz",

View File

@ -57,6 +57,7 @@
"react-dom": "^16.4.1",
"react-fontawesome": "^1.6.1",
"react-json-tree": "^0.11.0",
"react-json-view": "^1.19.1",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-scroll-to-component": "^1.0.2",

View File

@ -117,7 +117,9 @@ export const commands = {
{
timestamp: new Date().getTime(),
name: EMBARK_PROCESS_NAME,
msg: `console> ${payload.command}<br>${ansiToHtml(command.result)}`
msg: `console> ${payload.command}<br>${ansiToHtml(command.result)}`,
command: `console> ${payload.command}<br>`,
result: command.result
}
]
});

View File

@ -5,6 +5,7 @@ import Convert from 'ansi-to-html';
import { Col, Row, Card, CardBody, CardFooter, TabContent, TabPane, Nav, NavItem, NavLink } from 'reactstrap';
import classnames from 'classnames';
import {AsyncTypeahead} from 'react-bootstrap-typeahead'
import ReactJson from 'react-json-view';
import Logs from "./Logs";
import "./Console.css";
@ -67,8 +68,17 @@ class Console extends Component {
{processLogs
.filter((item) => item.name === process.name)
.reverse()
.map((item, i) => <p key={i} className={item.logLevel}
dangerouslySetInnerHTML={{__html: convert.toHtml(item.msg)}}></p>)}
.map((item, i) => {
if (item.result && item.result[0] === "{") {
return(
<ReactJson src={JSON.parse(item.result)} theme="monokai" sortKeys={true} collapsed={1} />
)
}
<p key={i} className={item.logLevel} dangerouslySetInnerHTML={{__html: convert.toHtml(item.msg)}}></p>
})
}
</Logs>
</TabPane>
))}