Skip to content
Snippets Groups Projects
Commit d341aaf8 authored by Imre Toth's avatar Imre Toth
Browse files

Merge branch 'ICSHWI-11079_Modifying_log_configuration' into 'develop'

ICSHWI-11079: Modifying log configuration"

See merge request !267
parents 58d8fb11 9d239f91
No related branches found
No related tags found
2 merge requests!270Merging develop branch to master in order to create RC,!267ICSHWI-11079: Modifying log configuration"
Pipeline #137664 passed
...@@ -761,7 +761,7 @@ export function unpackLokilog(logData) { ...@@ -761,7 +761,7 @@ export function unpackLokilog(logData) {
return { ...logData }; return { ...logData };
} }
export function useLokiSysLog() { export function useLokiSysLog(onError) {
const api = useContext(apiContext); const api = useContext(apiContext);
const method = useCallAndUnpack( const method = useCallAndUnpack(
(hostName, timeRange) => (hostName, timeRange) =>
...@@ -771,10 +771,10 @@ export function useLokiSysLog() { ...@@ -771,10 +771,10 @@ export function useLokiSysLog() {
}), }),
unpackLokilog unpackLokilog
); );
return useAsync({ fcn: method, call: false }); return useAsync({ fcn: method, call: false, onError: onError });
} }
export function useLokiProcServLog() { export function useLokiProcServLog(onError) {
const api = useContext(apiContext); const api = useContext(apiContext);
const method = useCallAndUnpack( const method = useCallAndUnpack(
(hostName, iocName, timeRange) => (hostName, iocName, timeRange) =>
...@@ -786,7 +786,7 @@ export function useLokiProcServLog() { ...@@ -786,7 +786,7 @@ export function useLokiProcServLog() {
unpackLokilog unpackLokilog
); );
return useAsync({ fcn: method, call: false }); return useAsync({ fcn: method, call: false, onError: onError });
} }
export function unpackIocStatus(status) { export function unpackIocStatus(status) {
......
...@@ -46,19 +46,26 @@ const useStyles = makeStyles((theme) => ({ ...@@ -46,19 +46,26 @@ const useStyles = makeStyles((theme) => ({
const LOG_POLL_INTERVAL = 5000; const LOG_POLL_INTERVAL = 5000;
export function LokiPanel({ host, iocName, isSyslog, isDeployed }) { export function LokiPanel({ host, iocName, isSyslog, isDeployed }) {
const showWarning = useCustomSnackbar();
function onError(message) {
showWarning(message, "warning");
}
const classes = useStyles(); const classes = useStyles();
const hostName = host.csEntryHost.name; const hostName = host.csEntryHost.name;
const [logData, getLogData /* reset*/, , logDataLoading] = useLokiSysLog(); const [logData, getLogData /* reset*/, , logDataLoading] =
useLokiSysLog(onError);
const [procServLog, getProcServLog /* reset*/, , procServLoading] = const [procServLog, getProcServLog /* reset*/, , procServLoading] =
useLokiProcServLog(); useLokiProcServLog(onError);
const [timeRange, setTimeRange] = React.useState(60); const [timeRange, setTimeRange] = React.useState(720);
const [timeRangeText, setTimeRangeText] = React.useState("12 hours");
const [periodChange, setPeriodChange] = useState(false); const [periodChange, setPeriodChange] = useState(false);
const showWarning = useCustomSnackbar("warning");
const handleChange = (event) => { const handleChange = (event) => {
setPeriodChange(true); setPeriodChange(true);
setTimeRange(event.target.value); setTimeRange(event.target.value);
setTimeRangeText(event.currentTarget.innerText);
}; };
// remove progressBar if intervall has been changed, and data received // remove progressBar if intervall has been changed, and data received
...@@ -110,7 +117,6 @@ export function LokiPanel({ host, iocName, isSyslog, isDeployed }) { ...@@ -110,7 +117,6 @@ export function LokiPanel({ host, iocName, isSyslog, isDeployed }) {
value={timeRange} value={timeRange}
onChange={handleChange} onChange={handleChange}
> >
<MenuItem value={60}>1 hour</MenuItem>
<MenuItem value={720}>12 hours</MenuItem> <MenuItem value={720}>12 hours</MenuItem>
<MenuItem value={10080}>7 days</MenuItem> <MenuItem value={10080}>7 days</MenuItem>
</Select> </Select>
...@@ -136,7 +142,8 @@ export function LokiPanel({ host, iocName, isSyslog, isDeployed }) { ...@@ -136,7 +142,8 @@ export function LokiPanel({ host, iocName, isSyslog, isDeployed }) {
logData, logData,
procServLog, procServLog,
isDeployed, isDeployed,
showWarning showWarning,
timeRangeText
)} )}
dataReady={dataReady} dataReady={dataReady}
extraClass={isDeployed ? classes.deployed : classes.undeployed} extraClass={isDeployed ? classes.deployed : classes.undeployed}
...@@ -160,13 +167,14 @@ function logsToPreprocess( ...@@ -160,13 +167,14 @@ function logsToPreprocess(
logData, logData,
procServLog, procServLog,
isDeployed, isDeployed,
showWarning showWarning,
timeRangeText
) { ) {
if (isSysLog === true) { if (isSysLog === true) {
return preprocessLog(logData, true, showWarning); return preprocessLog(logData, true, showWarning, timeRangeText);
} }
return preprocessLog(procServLog, isDeployed, showWarning); return preprocessLog(procServLog, isDeployed, showWarning, timeRangeText);
} }
function formatLogLine(logLine) { function formatLogLine(logLine) {
...@@ -182,9 +190,9 @@ function formatLogLine(logLine) { ...@@ -182,9 +190,9 @@ function formatLogLine(logLine) {
); );
} }
function preprocessLog(logData, isDeployed, showWarning) { function preprocessLog(logData, isDeployed, showWarning, timeRangeText) {
if (logData.warning) { if (logData.warning) {
showWarning(logData.warning); showWarning(logData.warning, "warning");
} }
if (logData && logData.lines?.length > 0) { if (logData && logData.lines?.length > 0) {
...@@ -204,5 +212,5 @@ function preprocessLog(logData, isDeployed, showWarning) { ...@@ -204,5 +212,5 @@ function preprocessLog(logData, isDeployed, showWarning) {
} }
} }
return "<html><body> - No messages found for period - </body></html>"; return `<html><body> - No messages found for ${timeRangeText} period - </body></html>`;
} }
...@@ -14,11 +14,11 @@ const useStyles = makeStyles((theme) => ({ ...@@ -14,11 +14,11 @@ const useStyles = makeStyles((theme) => ({
} }
})); }));
export function useCustomSnackbar(severity = "error") { export function useCustomSnackbar() {
const { enqueueSnackbar, closeSnackbar } = useSnackbar(); const { enqueueSnackbar, closeSnackbar } = useSnackbar();
const classes = useStyles(); const classes = useStyles();
function showError(errorMessage) { function showError(errorMessage, severity = "error") {
console.log("Snackbar: " + errorMessage); console.log("Snackbar: " + errorMessage);
const action = (key) => ( const action = (key) => (
<Button <Button
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment