Commit eaa833ea authored by 陈前坚's avatar 陈前坚

perf: log

parent 947a6457
...@@ -6,12 +6,11 @@ import { ...@@ -6,12 +6,11 @@ import {
Col, Col,
Button, Button,
Select, Select,
Menu,
notification, notification,
message, message,
Spin, Spin,
} from 'antd'; } from 'antd';
import { SwapRightOutlined, DownOutlined } from '@ant-design/icons'; import { SwapRightOutlined } from '@ant-design/icons';
import { Chart, Interval, Tooltip, Axis } from 'bizcharts'; import { Chart, Interval, Tooltip, Axis } from 'bizcharts';
import { DataSet } from '@antv/data-set'; import { DataSet } from '@antv/data-set';
import moment from 'moment'; import moment from 'moment';
...@@ -31,9 +30,73 @@ const ServiceLog = () => { ...@@ -31,9 +30,73 @@ const ServiceLog = () => {
const [logType, setLogType] = useState(0); // 请求参数,日志类型,默认是正常,0:成功 -1:错误 9999:全部 const [logType, setLogType] = useState(0); // 请求参数,日志类型,默认是正常,0:成功 -1:错误 9999:全部
const [tableColumns, setTableColumns] = useState([]); // 源数据 const [tableColumns, setTableColumns] = useState([]); // 源数据
console.log(startTime.format('HH:mm:ss')); const columns11 = [
console.log(endTime.format('HH:mm:ss')); {
title: '调用时间',
dataIndex: 'CallTime',
key: 'CallTime',
// filters: orgFilters,
// onFilter: (value, record) => record.OUName === value,
},
{
title: 'IP',
dataIndex: 'IP',
key: 'IP',
},
{
title: '接口名称',
dataIndex: 'Path',
key: 'Path',
width: 200,
ellipsis: true,
},
{
title: '请求方法',
dataIndex: 'Method',
key: 'Method',
ellipsis: true,
},
{
title: '查询参数',
dataIndex: 'QueryString',
key: 'QueryString',
width: 150,
ellipsis: true,
},
{
title: '请求体',
dataIndex: 'Body',
key: 'Body',
width: 200,
ellipsis: true,
},
{
title: '状态码',
dataIndex: 'Result',
key: 'Result',
},
{
title: '耗时/ms',
dataIndex: 'ConsumerTime',
key: 'ConsumerTime',
defaultSortOrder: 'descend',
sorter: (a, b) => a.ConsumerTime - b.ConsumerTime,
},
{
title: '返回体大小/byte',
dataIndex: 'ResponseSize',
key: 'ResponseSize',
ellipsis: true,
sorter: (a, b) => a.ResponseSize - b.ResponseSize,
},
{
title: '错误信息',
dataIndex: 'ErrorMsg',
key: 'ErrorMsg',
width: 200,
ellipsis: true,
},
];
// 在起止时间任意一个变化后获取数据 // 在起止时间任意一个变化后获取数据
useEffect(() => { useEffect(() => {
if (startTime && endTime) { if (startTime && endTime) {
...@@ -45,10 +108,10 @@ const ServiceLog = () => { ...@@ -45,10 +108,10 @@ const ServiceLog = () => {
post(`${PUBLISH_SERVICE}/LogCenter/GetOMSLog`, { post(`${PUBLISH_SERVICE}/LogCenter/GetOMSLog`, {
PageIndex: 0, PageIndex: 0,
PageSize: 0, PageSize: 0,
DateFrom: startTime.format('YYYY-MM-DD'), DateFrom: startTime.format('YYYY-MM-DD HH:mm:ss'),
DateTo: endTime.format('YYYY-MM-DD'), DateTo: endTime.format('YYYY-MM-DD HH:mm:ss'),
HourFrom: startTime.format('HH:mm:ss'), // HourFrom: startTime.format('HH:mm:ss'),
HourTo: endTime.format('HH:mm:ss'), // HourTo: endTime.format('HH:mm:ss'),
IP: '', IP: '',
Module: '', Module: '',
LogType: +logType, LogType: +logType,
...@@ -79,12 +142,28 @@ const ServiceLog = () => { ...@@ -79,12 +142,28 @@ const ServiceLog = () => {
item.key = index; item.key = index;
return item; return item;
}); });
const columns = Object.keys(data[0]).map(key => ({ // const columns = Object.keys(data[0]).map(key => {
title: key, // if (key === 'ResponseSize') {
dataIndex: key, // return {
key, // title: key,
})); // dataIndex: key,
setTableColumns(columns); // key,
// defaultSortOrder: 'descend',
// sorter: (a, b) => a.ResponseSize - b.ResponseSize,
// };
// }
// if (key === 'Body' || key === 'QueryString' || key === 'Path') {
// return {
// title: key,
// dataIndex: key,
// key,
// width: 150,
// ellipsis: true,
// };
// }
// return { title: key, dataIndex: key, key };
// });
// setTableColumns(columns);
// console.log(Object.keys(data[0])); // console.log(Object.keys(data[0]));
const scale1 = { const scale1 = {
Path: { Path: {
...@@ -148,6 +227,7 @@ const ServiceLog = () => { ...@@ -148,6 +227,7 @@ const ServiceLog = () => {
), ),
); );
}; };
// 设置日志类型
const selectChange = value => { const selectChange = value => {
setLogType(value); setLogType(value);
}; };
...@@ -235,7 +315,7 @@ const ServiceLog = () => { ...@@ -235,7 +315,7 @@ const ServiceLog = () => {
<Table <Table
size="small" size="small"
bordered bordered
columns={tableColumns || []} columns={columns11}
dataSource={data0} dataSource={data0}
scroll={{ x: 'max-content' }} scroll={{ x: 'max-content' }}
pagination={{ pagination={{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment