@viplance/nestjs-logger 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
<li class="verbose" data-selector="verbose">Verbose</li>
|
|
42
42
|
</ul>
|
|
43
43
|
</nav>
|
|
44
|
+
<input id="search" onkeyup="search(event)" type="text" placeholder="Search" />
|
|
44
45
|
<div onclick="getLogs()"><button class="white">Refresh</button></div>
|
|
45
46
|
</div>
|
|
46
47
|
<div class="container table-header">
|
package/public/scripts/common.js
CHANGED
|
@@ -10,6 +10,7 @@ const selectedLogTypes = {
|
|
|
10
10
|
const logTypes = Object.keys(selectedLogTypes).filter((key) => key !== `all`);
|
|
11
11
|
|
|
12
12
|
let logs = [];
|
|
13
|
+
let text = "";
|
|
13
14
|
|
|
14
15
|
window.addEventListener("load", async () => {
|
|
15
16
|
getLogs();
|
|
@@ -37,7 +38,7 @@ document.addEventListener(`click`, (e) => {
|
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
renderLogs();
|
|
41
42
|
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
@@ -132,6 +133,31 @@ function getLogHtmlElement(log) {
|
|
|
132
133
|
</div>`;
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
function renderLogs() {
|
|
137
|
+
let html = "";
|
|
138
|
+
|
|
139
|
+
logs
|
|
140
|
+
.filter((log) => {
|
|
141
|
+
return selectedLogTypes["all"] || selectedLogTypes[log.type];
|
|
142
|
+
})
|
|
143
|
+
.filter((log) => {
|
|
144
|
+
if (text === "") return true;
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
log.message.toLowerCase().includes(text) ||
|
|
148
|
+
log.trace?.toLowerCase().includes(text) ||
|
|
149
|
+
JSON.stringify(log.context || {})
|
|
150
|
+
.toLowerCase()
|
|
151
|
+
.includes(text)
|
|
152
|
+
);
|
|
153
|
+
})
|
|
154
|
+
.forEach((log) => {
|
|
155
|
+
html += getLogHtmlElement(log);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
document.getElementById("logs").innerHTML = html;
|
|
159
|
+
}
|
|
160
|
+
|
|
135
161
|
async function getLogs() {
|
|
136
162
|
const { origin, pathname, search } = window.location;
|
|
137
163
|
const res = await fetch(`${origin}${pathname}api${search}`);
|
|
@@ -149,16 +175,12 @@ async function getLogs() {
|
|
|
149
175
|
document.querySelector("nav").style.display = "flex";
|
|
150
176
|
}
|
|
151
177
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
178
|
+
renderLogs();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
155
181
|
|
|
156
|
-
|
|
182
|
+
function search(event) {
|
|
183
|
+
text = event.target.value.toLowerCase();
|
|
157
184
|
|
|
158
|
-
|
|
159
|
-
html += getLogHtmlElement(log);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
document.getElementById("logs").innerHTML = html;
|
|
163
|
-
}
|
|
185
|
+
renderLogs();
|
|
164
186
|
}
|
|
@@ -9,7 +9,7 @@ function showLogDetails(log) {
|
|
|
9
9
|
${
|
|
10
10
|
log.trace
|
|
11
11
|
? `
|
|
12
|
-
<h3 class="mt-
|
|
12
|
+
<h3 class="mt-15">Trace</h3>
|
|
13
13
|
<p class="key pl-2"><span>${getTrace(log.trace)}</span></p>
|
|
14
14
|
`
|
|
15
15
|
: ""
|
|
@@ -17,7 +17,7 @@ function showLogDetails(log) {
|
|
|
17
17
|
${
|
|
18
18
|
log.context
|
|
19
19
|
? `
|
|
20
|
-
<h3 class="mt-
|
|
20
|
+
<h3 class="mt-15">Context</h3>
|
|
21
21
|
<p>${jsonViewer(log.context)}</p>
|
|
22
22
|
`
|
|
23
23
|
: ""
|
|
@@ -25,7 +25,7 @@ function showLogDetails(log) {
|
|
|
25
25
|
${
|
|
26
26
|
log.breadcrumbs && log.breadcrumbs.length > 0
|
|
27
27
|
? `
|
|
28
|
-
<h3 class="mt-
|
|
28
|
+
<h3 class="mt-15">Breadcrumbs</h3>
|
|
29
29
|
<p>${jsonViewer(log.breadcrumbs)}</p>
|
|
30
30
|
`
|
|
31
31
|
: ""
|
|
@@ -19,7 +19,7 @@ function jsonViewer(json, parentKey) {
|
|
|
19
19
|
const showParentKey = parentKey && keys.length > 0; // hide an empty object
|
|
20
20
|
|
|
21
21
|
if (showParentKey) {
|
|
22
|
-
res += `<div class="pl-2"><div
|
|
22
|
+
res += `<div class="pl-2"><div>▾ ${parentKey}</div>`;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
for (const key of keys) {
|
package/public/styles/index.css
CHANGED
|
@@ -169,6 +169,9 @@ nav ul li:hover {
|
|
|
169
169
|
.mt-1 {
|
|
170
170
|
margin-top: 1rem;
|
|
171
171
|
}
|
|
172
|
+
.mt-15 {
|
|
173
|
+
margin-top: 1.5rem;
|
|
174
|
+
}
|
|
172
175
|
.mt-2 {
|
|
173
176
|
margin-top: 2rem;
|
|
174
177
|
}
|
|
@@ -180,6 +183,13 @@ nav ul li:hover {
|
|
|
180
183
|
padding-left: 2rem;
|
|
181
184
|
}
|
|
182
185
|
|
|
186
|
+
#search {
|
|
187
|
+
outline: none;
|
|
188
|
+
padding: 0.5rem;
|
|
189
|
+
border: 1px solid var(--light);
|
|
190
|
+
font-size: 1rem;
|
|
191
|
+
}
|
|
192
|
+
|
|
183
193
|
/* table */
|
|
184
194
|
.table-header,
|
|
185
195
|
.row {
|
|
@@ -190,10 +200,10 @@ nav ul li:hover {
|
|
|
190
200
|
align-items: center;
|
|
191
201
|
justify-content: space-around;
|
|
192
202
|
}
|
|
193
|
-
|
|
194
203
|
.table-header {
|
|
195
|
-
display:
|
|
204
|
+
display: flex;
|
|
196
205
|
height: 2rem;
|
|
206
|
+
justify-content: space-between;
|
|
197
207
|
background-color: var(--dark);
|
|
198
208
|
color: var(--white);
|
|
199
209
|
margin-top: 0.5rem;
|
|
@@ -208,12 +218,10 @@ nav ul li:hover {
|
|
|
208
218
|
flex: 0 0 5rem;
|
|
209
219
|
text-align: center;
|
|
210
220
|
}
|
|
211
|
-
|
|
212
|
-
.table-header > :nth-child(2),
|
|
213
221
|
.row > :nth-child(2) {
|
|
214
222
|
flex: 0 0 auto;
|
|
223
|
+
max-width: 35rem;
|
|
215
224
|
}
|
|
216
|
-
.table-header > :nth-child(3),
|
|
217
225
|
.row > :nth-child(3) {
|
|
218
226
|
flex: 1 1 auto;
|
|
219
227
|
}
|