-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
54 lines (42 loc) · 1.22 KB
/
index.js
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
// const axios = require("axios");
const logTypes = {
LOG: "LOG",
INFO: "INFO",
ERROR: "ERROR",
WARN: "WARN",
};
let url;
function postData(logs, type) {
if (typeof url !== "string") {
return console.warn("HypeBeats initialization failure: \n\n\tnew HypeBeats() \n\n\t^logStoreURL is undefined");
}
// axios.post(url, { logs, type })
// .then(res => console.log(res.data))
// .catch(err => console.error("Beats error: ", err.response || err));
}
class HypeBeats {
constructor(logStoreURL) {
url = logStoreURL;
}
// log
log(logs) {
console.log("%c HypeLog: ", "background: #374046; color: #fff", logs);
postData(logs, logTypes.LOG);
}
// info
info(logs) {
console.info("%c HypeInfo: ", "background: #2196F3; color: #fff", logs);
postData(logs, logTypes.INFO);
}
// error
error(logs) {
console.error("%c HypeError: ", "background: #F44336; color: #fff", logs);
postData(logs, logTypes.ERROR);
}
// warn
warn(logs) {
console.warn("%c HypeWarn: ", "background: #FF9800; color: #fff", logs);
postData(logs, logTypes.WARN);
}
}
module.exports = HypeBeats;