mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* feat: add clear logs to explorer's live logs * refactor live logs pause/resume updating logic * add tests for clearing live logs * rm unused imports * move `onClear` live logs logic to redux * move clear logs tests to `query.test` * use utils `sortLogsRows` and Button's icon props * rename `filterLogRows` and add `clearedAt` as an arg * mv clearedAt type closer to live tailing items and add jsdoc * mv `filterLogRowsByTime` to `/utils` and use it at `LiveLogs` component * make `Exit live` button consistent with other actions * use `sortLogRows` and fix timestamp by id on `makeLogs` * change clear live logs from based on timestamp to index on logRows * assign `null` to `clearedAtIndex` on first batch of logs live * move `isFirstStreaming` implementation to `clearLogs` reducer * fix `clearLogs` tests * Update public/app/features/explore/state/query.ts Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> --------- Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
33 lines
986 B
TypeScript
33 lines
986 B
TypeScript
import { MutableDataFrame, LogLevel, LogRowModel, LogsSortOrder } from '@grafana/data';
|
|
import { sortLogRows } from 'app/features/logs/utils';
|
|
export const makeLogs = (numberOfLogsToCreate: number, overrides?: Partial<LogRowModel>): LogRowModel[] => {
|
|
const array: LogRowModel[] = [];
|
|
|
|
for (let i = 0; i < numberOfLogsToCreate; i++) {
|
|
const uuid = (i + 1).toString();
|
|
const entry = `log message ${uuid}`;
|
|
const timeInMs = overrides?.timeEpochMs || new Date().getTime();
|
|
|
|
array.push({
|
|
uid: uuid,
|
|
entryFieldIndex: 0,
|
|
rowIndex: 0,
|
|
dataFrame: new MutableDataFrame(),
|
|
logLevel: LogLevel.debug,
|
|
entry,
|
|
hasAnsi: false,
|
|
hasUnescapedContent: false,
|
|
labels: {},
|
|
raw: entry,
|
|
timeFromNow: '',
|
|
timeEpochMs: timeInMs + i,
|
|
timeEpochNs: (timeInMs * 1000000 + i).toString(),
|
|
timeLocal: '',
|
|
timeUtc: '',
|
|
...overrides,
|
|
});
|
|
}
|
|
|
|
return sortLogRows(array, LogsSortOrder.Ascending);
|
|
};
|