xref: /aosp_15_r20/external/pigweed/pw_web/log-viewer/src/shared/interfaces.ts (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1// Copyright 2023 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14
15export interface Field {
16  key: string;
17  value: string | boolean | number | object;
18}
19
20export interface TableColumn {
21  fieldName: string;
22  characterLength: number;
23  manualWidth: number | null;
24  isVisible: boolean;
25}
26
27export interface LogEntry {
28  severity?: Level;
29  level?: Level;
30  timestamp: Date;
31  fields: Field[];
32  sourceData?: SourceData;
33}
34
35export enum Level {
36  DEBUG = 'DEBUG',
37  INFO = 'INFO',
38  WARNING = 'WARNING',
39  ERROR = 'ERROR',
40  CRITICAL = 'CRITICAL',
41}
42
43export enum Severity {
44  DEBUG = 'DEBUG',
45  INFO = 'INFO',
46  WARNING = 'WARNING',
47  ERROR = 'ERROR',
48  CRITICAL = 'CRITICAL',
49}
50
51export interface LogEntryEvent {
52  type: 'log-entry';
53  data: LogEntry;
54}
55
56// Union type for all log source event types
57export type LogSourceEvent = LogEntryEvent /* | ... */;
58
59export interface SourceData {
60  id: string;
61  name: string;
62}
63