-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathindex.html
276 lines (253 loc) · 11.1 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="robots" content="index,follow">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Debugout.js</title>
<link rel="stylesheet" type="text/css" href="https://inorganik.github.io/assets/css/style.css?v=20191111">
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-7742845-9', 'inorganik.github.io');
ga('send', 'pageview');
</script>
</head>
<body>
<a class="forkMe" href="https://github.com/inorganik/debugout.js"><img
src="https://inorganik.github.io/assets/img/forkme_custom_indigo.png" alt="Fork me on GitHub"></a>
<div id="wrap">
<header>
<div id="github"><a class="block" href="https://github.com/inorganik"></a></div>
<div class="leaderLine">
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
</div>
<div id="logo"><a class="block" href="http://inorganik.github.io"></a></div>
</header>
<section>
<h1>debugout.js <small id="version" class="lt-gray"></small></h1>
<p>debugout.js (debug output) generates a text file from your logs that can be searched, timestamped,
downloaded and more. See examples and usage on GitHub.</p>
<p>Install via npm/yarn using the package name <code class="indigo large">debugout.js</code>.</p>
<h3 class="marginTop marginBottom"><a class="lime weight700"
href="https://github.com/inorganik/debugout.js">Download on GitHub</a></h3>
</section>
<section>
<div class="col-inner-no-lr">
<p class="large weight300">Create a new debugout object and replace "console" with your instance of Debugout. Try it in your console using "bugout" instead of "console".</p>
<p class="large weight300 noMargin"> The following logs (in purple) produce the output (in green) below:</p>
</div>
</section>
<section>
<div class="col full marginTop">
<div class="code-contain marginBottom indigo">
<code>const bugout = new Debugout();<br>
bugout.warn('a warning');<br>
bugout.error('an error');<br>
bugout.log('A date:', d);<br>
bugout.log('An array:', arr);<br>
bugout.log('A function:', testFunc);<br>
bugout.log('A regex', rgx);<br>
bugout.log('an object with nested objects and arrays...', obj);<br>
bugout.log('an array of objects...', arrayWithObjects);<br>
</code>
</div>
</div>
</section>
<section>
<form>
<h4 class="inlineLeft noMargin marginRight weight300">Get the log at run-time or any time with these
methods:</h4>
<input type="button" class="inlineLeft marginRight" value="download log" id="downloadLog">
<input type="button" class="inlineLeft marginRight" value="get log" id="getLog" style="width:100px;">
<input type="button" class="inlineLeft marginRight" value="tail" id="tail" style="width:100px;">
</form>
</section>
<section>
<form>
<h4 class="inlineLeft noMargin marginRight weight300">Also, search:</h4>
<input type="text" class="inlineLeft" value="" id="search" style="width:140px; margin-right:5px"
placeholder="ex: subgenre">
<input type="button" class="inlineLeft marginRight" value="search" id="doSearch" style="width:100px;">
<h4 class="inlineLeft noMargin marginRight weight300">And slice:</h4>
<input type="number" class="inlineLeft" value="" step="1" id="sliceStart" style="width:80px; margin-right:5px"
placeholder="line">
<input type="number" class="inlineLeft marginRight" value="" step="1" id="sliceEnd" style="width:80px"
placeholder="# of lines">
<input type="button" class="inlineLeft marginRight" value="get slice" id="doSlice" style="width:100px">
<h4 class="inlineLeft noMargin marginRight weight300">Also:</h4>
<input type="button" class="inlineLeft" value="clear" id="doClear" style="width:100px;">
</form>
</section>
<section>
<form>
<h4 class="inlineLeft noMargin weight300">Options:</h4>
<div class="inlineLeft marginLeft marginRight">
<input class="onchange" id="realTimeLoggingOn" type="checkbox" checked><label class="inlineLabel">realTimeLoggingOn</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" id="useTimestamps" type="checkbox"><label class="inlineLabel">useTimestamps</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" id="includeSessionMetadata" type="checkbox" checked> <label class="inlineLabel">includeSessionMetadata</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" id="useLocalStorage" type="checkbox"> <label class="inlineLabel">useLocalStorage</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" id="recordLogs" type="checkbox" checked> <label class="inlineLabel">recordLogs</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" id="autoTrim" type="checkbox" checked> <label class="inlineLabel">autoTrim</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" id="quoteStrings" type="checkbox" checked> <label class="inlineLabel">quoteStrings</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" type="text" value="debugout.txt" id="logFilename" style="width:100px; padding:0 5px;">
<label class="inlineLabel">logFilename</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" type="text" value="3000" id="maxLines" style="width:50px; padding:0 5px;">
<label class="inlineLabel">maxLines</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" type="text" value="20" id="maxDepth" style="width:40px; padding:0 5px;">
<label class="inlineLabel">maxDepth</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" type="text" value="debugout.js" id="localStorageKey" style="width:100px; padding:0 5px;">
<label class="inlineLabel">localStorageKey</label>
</div>
<div class="inlineLeft marginRight">
<input class="onchange" type="text" value=" " id="indent" style="width:50px; padding:0 5px;">
<label class="inlineLabel">indent</label>
</div>
</form>
</section>
<section class="marginBottom">
<div class="col full marginBottom marginTop">
<h4 class="weight300">Console window:</h4>
<div class="code-contain marginBottom lime" style="min-height:500px">
<code id="codeVisualizer">// Use a method above and output will be displayed here</code>
</div>
</div>
</section>
</div>
</body>
<script type="module">
import { Debugout } from './dist/debugout.js'
const el = (id) => document.getElementById(id);
// a test object
const obj = {
name: 'Jamie',
arr: ['red', 'gold', 'green', 4, true, false],
emptyString: '',
nestedObj: {
apple: 'red',
orange: 'orange',
pear: 'green',
nestedNestedObj: {
red: 0,
yellow: 6,
green: 4
}
},
date: new Date(),
flag: true,
anotherFlag: false,
}
// a date
const d = new Date();
// an array
const arr = ['some', 'test', 'array'];
// a function
const testFunc = function () {
return 'oh heck ya debugout';
}
// a regex
const rgx = new RegExp(/debugout/gi);
// array with objects
const songOne = { genre: 'Drum \'n Bass', subgenre: 'liquid' }
const songTwo = { genre: 'Dubstep', subgenre: 'brostep', someArray: arr }
const songThree = { genre: 'R&B', subgenre: 'soul revival' }
const arrayWithObjects = [songOne, songTwo, songThree];
function displayOutput(output) {
// format for html
output = output.replace(/\n/g, '<br>').replace(/ /g, ' ');
el('codeVisualizer').innerHTML = output;
}
function establishOptionsFromInputs() {
return {
realTimeLoggingOn: el('realTimeLoggingOn').checked,
useTimestamps: el('useTimestamps').checked,
includeSessionMetadata: el('includeSessionMetadata').checked,
useLocalStorage: el('useLocalStorage').checked,
recordLogs: el('recordLogs').checked,
autoTrim: el('autoTrim').checked,
quoteStrings: el('quoteStrings').checked,
logFilename: el('logFilename').value,
maxLines: Number(el('maxLines').value),
maxDepth: Number(el('maxDepth').value),
localStorageKey: el('localStorageKey').value,
indent: el('indent').value,
};
}
function logStuff() {
const options = establishOptionsFromInputs();
window.bugout = new Debugout(options);
bugout.warn('a warning');
bugout.error('an error');
bugout.log('A date:', d);
bugout.log('An array:', arr);
bugout.log('A function:', testFunc);
bugout.log('A regex:', rgx);
bugout.log('an object with nested objects and arrays...', obj);
bugout.log('an array of objects...', arrayWithObjects);
displayOutput(bugout.getLog());
}
window.onload = function () {
logStuff();
document.getElementById('version').innerHTML = 'v' + bugout.version();
document.querySelectorAll('.onchange').forEach(el => el.onchange = logStuff);
el('getLog').onclick = () => {
let output = bugout.getLog();
output += 'bugout.getLog();\n'
displayOutput(output);
}
el('downloadLog').onclick = () => {
let output = bugout.getLog();
output += 'bugout.downloadLog();';
bugout.downloadLog();
displayOutput(output);
}
el('tail').onclick = () => {
let output = 'bugout.tail(20);\n';
output += bugout.tail(20);
displayOutput(output);
}
el('doSearch').onclick = () => {
const term = el('search').value;
let output = "bugout.search('" + term + "');\n";
output += bugout.search(term);
displayOutput(output);
}
el('doSlice').onclick = () => {
const startLine = Number(el('sliceStart').value);
const endLine = Number(el('sliceEnd').value);
let output = 'bugout.slice(' + startLine + ', ' + endLine + ');\n\n';
output += bugout.slice(startLine, endLine);
displayOutput(output);
}
el('doClear').onclick = () => {
bugout.clear(true);
displayOutput(bugout.getLog());
}
}
</script>
</html>