-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
186 lines (165 loc) · 6.23 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!Doctype html>
<html lang="en">
<head>
<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.21.1/babel.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script
src="https://unpkg.com/react-bootstrap@next/dist/react-bootstrap.min.js"
crossorigin></script>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
crossorigin="anonymous"
/>
<script src="/LogsAnalytics.js"></script>
<style>
body {
padding: 1em;
}
.info {
color: blue
}
.debug {
color: green
}
.warning {
color: orange
}
.error .critical {
color: red
}
pre {
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</style>
<script type="text/babel">
window.onload = function () {
const Form = ReactBootstrap.Form
const Row = ReactBootstrap.Row
const Col = ReactBootstrap.Col
const Container = ReactBootstrap.Container
const min_log_severity = "min_log_severity"
function Main(props){
const [logsAnalytics, setLogsAnalytics] = React.useState(undefined)
const [filter, setFilter] = React.useState({
min_log_severity: 1,
from: 0,
text: "",
type: ""
})
function updateFilter(field, value){
console.log(field, value)
filter[field] = value
setFilter({...filter})
}
if (logsAnalytics === undefined){
axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*'
axios.get('/autoinst-log.txt').then((result)=>{
console.log(result.data)
setLogsAnalytics(new LogsAnalytics(result.data))
})
return <p>Loading...</p>
}
let logs = logsAnalytics.filter([
function filter_min_log_severity(item){
return item.numericSeverity >= filter.min_log_severity
},
function filter_from(item){
return item.$pos >= filter.from
},
function filter_text(item){
return item.message !== undefined && item.message.search(filter.text) !== -1
},
function filter_type(item){
return filter.type === "" || item.$type === filter.type
}
])
let from_filter_last = undefined
return <div>
<Container style={{padding: "2em"}}>
<Row>
<Col>
<Form.Group controlId="min-log-severity">
<Form.Label>Min log severity</Form.Label>
<Form.Control as="select" onChange={ e => updateFilter(min_log_severity, e.target.value)}>
<option value="1">Debug</option>
<option value="2">Info</option>
<option value="3">Warning</option>
<option value="4">Error</option>
<option value="5">Critical</option>
</Form.Control>
</Form.Group>
</Col>
<Col>
<Form.Group controlId="From">
<Form.Label>From (time)</Form.Label>
<Form.Control as="select" onChange={ e => updateFilter("from", e.target.value)}>
{logsAnalytics.logs.map( log => {
let time = log.timestamp.format("LTS")
if (from_filter_last != time){
from_filter_last = time
return <option value={log.$pos}>{log.timestamp.format("LTS")}</option>
}
})}
</Form.Control>
</Form.Group>
</Col>
<Col>
<Form.Group controlId="From">
<Form.Label>Search</Form.Label>
<Form.Control onChange={ e=> updateFilter("text", e.target.value)}/>
</Form.Group>
</Col>
<Col>
<Form.Group controlId="type">
<Form.Label>Log type</Form.Label>
<Form.Control as="select" onChange={ e => updateFilter("type", e.target.value)}>
<option value="">all</option>
{[...new Set(logsAnalytics.logs.map( log => log.$type))].map( type =>{
return <option>{type}</option>
})}
</Form.Control>
</Form.Group>
</Col>
</Row>
</Container>
<table class="table">
<tr>
<th style={{width:"8em"}}>Timestamp</th>
<th>Severity</th>
<th>Message</th>
<th>Type</th>
</tr>
{
logs.map(log => {
return <tr>
<td><b>{log.timestamp.format("LTS")}</b></td>
<td className={log.severity}>{log.severity}</td>
<td><pre>{log.message}</pre></td>
<td>{log.$type}</td>
</tr>
})
}
</table>
</div>
}
ReactDOM.render(
<Main/>,
document.getElementById('content')
);
}
</script>
</head>
<body>
<h1>autoinst-log Analytics & query</h1>
<div id="content"></div>
</body>
</html>