diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js index 99c4f7a45..c35986098 100644 --- a/embark-ui/src/actions/index.js +++ b/embark-ui/src/actions/index.js @@ -108,7 +108,7 @@ export const commands = { export const PROCESS_LOGS = createRequestTypes('PROCESS_LOGS'); export const processLogs = { - request: (processName) => action(PROCESS_LOGS[REQUEST], {processName}), + request: (processName, limit) => action(PROCESS_LOGS[REQUEST], {processName, limit}), success: (processLogs) => action(PROCESS_LOGS[SUCCESS], {processLogs}), failure: (error) => action(PROCESS_LOGS[FAILURE], {error}) }; diff --git a/embark-ui/src/constants.js b/embark-ui/src/constants.js index 82b245e3a..3e934af9b 100644 --- a/embark-ui/src/constants.js +++ b/embark-ui/src/constants.js @@ -1 +1,2 @@ -export const EMBARK_PROCESS_NAME = 'embark'; \ No newline at end of file +export const EMBARK_PROCESS_NAME = 'embark'; +export const LOG_LIMIT = 50; \ No newline at end of file diff --git a/embark-ui/src/containers/HomeContainer.js b/embark-ui/src/containers/HomeContainer.js index cb554ba7f..3c450780c 100644 --- a/embark-ui/src/containers/HomeContainer.js +++ b/embark-ui/src/containers/HomeContainer.js @@ -14,7 +14,7 @@ import { import DataWrapper from "../components/DataWrapper"; import Processes from '../components/Processes'; import Console from '../components/Console'; -import {EMBARK_PROCESS_NAME} from '../constants'; +import {EMBARK_PROCESS_NAME, LOG_LIMIT} from '../constants'; import ContractsList from '../components/ContractsList'; import {getContracts, getProcesses, getProcessLogs} from "../reducers/selectors"; @@ -39,10 +39,10 @@ class HomeContainer extends Component { if (processName === EMBARK_PROCESS_NAME) { if (this.props.processLogs.length === 0) { - this.props.fetchProcessLogs(processName); + this.props.fetchProcessLogs(processName, LOG_LIMIT); } } else { - this.props.fetchProcessLogs(processName); + this.props.fetchProcessLogs(processName, LOG_LIMIT); this.props.listenToProcessLogs(processName); } diff --git a/lib/core/processes/processLauncher.js b/lib/core/processes/processLauncher.js index 4fb23bc7d..034651e8d 100644 --- a/lib/core/processes/processLauncher.js +++ b/lib/core/processes/processLauncher.js @@ -85,7 +85,9 @@ class ProcessLauncher { 'get', apiRoute, (_req, res) => { - const result = self.logs.map((log, id) => Object.assign(log, {id})).slice(-50); + let limit = parseInt(req.query.limit, 10); + if(!Number.isInteger(limit)) limit = 0; + const result = self.logs.map((log, id) => Object.assign(log, {id})).slice(limit); res.send(JSON.stringify(result)); } );