Skip to content

Commit 27bfb02

Browse files
committed
simulation of logs; fix in scope
1 parent 0752ef5 commit 27bfb02

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

boscaiolog.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ window.bosco = {
55
endpoint: "https://qryn.endpoint.com",
66
log: async function (log_content) {
77
console.info(log_content) // don't do console.log or you'll create an infinite recursion
8-
this.send(log_content)
8+
window.bosco.send(log_content)
99
},
1010
init: function (options) {
1111
this.endpoint = options?.endpoint || this.endpoint
@@ -38,7 +38,7 @@ window.bosco = {
3838
if (!indexed_id) {
3939
var res = await fetch(this.endpoint + "/" + this.label + '/_doc/', {
4040
method: "POST",
41-
body: JSON.stringify(log_content)
41+
body: JSON.stringify(log_content),
4242
}).catch((err)=>{
4343
console.error(err)
4444
})

simulated.html

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=800px, initial-scale=1.0">
7+
<title>Boscaiolog Test</title>
8+
</head>
9+
<body>
10+
<input type="text" id="url"></input>
11+
<button id="start">Send</button>
12+
</body>
13+
<script src="./boscaiolog.js"></script>
14+
<script>
15+
window.bosco.init({
16+
consoleOverwrite: true,
17+
})
18+
let button = document.getElementById("start")
19+
20+
button.addEventListener("click", async function (ev) {
21+
let url = document.getElementById("url")
22+
window.bosco.endpoint = url.value
23+
console.log(window.bosco.endpoint)
24+
})
25+
26+
setInterval(sendALog, 10000)
27+
28+
function sendALog () {
29+
console.log({
30+
time: Date.now(),
31+
msg: 'Bosco simulator'
32+
})
33+
}
34+
</script>
35+
</html>

0 commit comments

Comments
 (0)