Further unify logging.

This commit is contained in:
Thomas E Lackey 2020-06-11 00:35:39 -05:00
parent c226486d05
commit 958821b9ae
3 changed files with 7 additions and 9 deletions

View File

@ -7,14 +7,16 @@ import { useQuery } from '@apollo/react-hooks';
import { ConsoleContext, useQueryStatusReducer } from '../hooks'; import { ConsoleContext, useQueryStatusReducer } from '../hooks';
import LOGS from '../gql/logs.graphql';
import Log from './Log'; import Log from './Log';
const MAX_LINES = 1000; const MAX_LINES = 1000;
const logBuffer = []; const logBuffer = [];
const LogPoller = ({ service, query }) => { const LogPoller = ({ service }) => {
const { config } = useContext(ConsoleContext); const { config } = useContext(ConsoleContext);
const data = useQueryStatusReducer(useQuery(query, { const data = useQueryStatusReducer(useQuery(LOGS, {
pollInterval: config.api.intervalLog, pollInterval: config.api.intervalLog,
variables: { service, incremental: logBuffer.length !== 0 } variables: { service, incremental: logBuffer.length !== 0 }
})); }));
@ -23,7 +25,7 @@ const LogPoller = ({ service, query }) => {
return null; return null;
} }
const { incremental, lines } = JSON.parse(data.wns_log.json); const { incremental, lines } = JSON.parse(data.logs.json);
if (!incremental && lines.length) { if (!incremental && lines.length) {
logBuffer.length = 0; logBuffer.length = 0;

View File

@ -9,8 +9,6 @@ import Tab from '@material-ui/core/Tab';
import Tabs from '@material-ui/core/Tabs'; import Tabs from '@material-ui/core/Tabs';
import TabContext from '@material-ui/lab/TabContext'; import TabContext from '@material-ui/lab/TabContext';
import SIGNAL_LOG from '../../../gql/logs.graphql';
import Panel from '../../../components/Panel'; import Panel from '../../../components/Panel';
import Toolbar from '../../../components/Toolbar'; import Toolbar from '../../../components/Toolbar';
@ -64,7 +62,7 @@ const Signal = () => {
{tab === TAB_LOG && ( {tab === TAB_LOG && (
<div className={classes.panel}> <div className={classes.panel}>
<LogPoller query={SIGNAL_LOG} /> <LogPoller service='signal' />
</div> </div>
)} )}
</TabContext> </TabContext>

View File

@ -9,8 +9,6 @@ import Tab from '@material-ui/core/Tab';
import Tabs from '@material-ui/core/Tabs'; import Tabs from '@material-ui/core/Tabs';
import TabContext from '@material-ui/lab/TabContext'; import TabContext from '@material-ui/lab/TabContext';
import WNS_LOG from '../../../gql/wns_log.graphql';
import LogPoller from "../../../components/LogPoller"; import LogPoller from "../../../components/LogPoller";
import Panel from '../../../components/Panel'; import Panel from '../../../components/Panel';
import Toolbar from '../../../components/Toolbar'; import Toolbar from '../../../components/Toolbar';
@ -78,7 +76,7 @@ const WNS = () => {
{tab === TAB_LOG && ( {tab === TAB_LOG && (
<div className={classes.panel}> <div className={classes.panel}>
<LogPoller query={WNS_LOG} /> <LogPoller service='wns-lite' />
</div> </div>
)} )}
</TabContext> </TabContext>