-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
51 lines (41 loc) · 1.04 KB
/
app.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
'use strict';
const Homey = require('homey');
const Logger = require('./captureLogs.js');
class Life360App extends Homey.App {
onInit() {
this.log(`${ Homey.manifest.id } V${Homey.manifest.version} is running...`);
// try {
// require('inspector').open(9229, '0.0.0.0', false);
// } catch (error) {
// console.log(error);
// }
this.logger = new Logger('log', 50);
// global crash handling
process.on('uncaughtException', (err) => {
this.error(`UnCaught exception: ${err}\n`);
});
process.on('unhandledRejection', (reason, p) => {
this.error('Unhandled Rejection at:', p, 'reason:', reason);
});
Homey
.on('unload', () => {
this.log('app unload called');
// save logs to persistant storage
this.logger.saveLogs();
})
.on('memwarn', () => {
this.log('memwarn!');
})
.on('cpuwarn', () => {
this.log('cpu warning');
});
}
// stuff for frontend API
deleteLogs() {
return this.logger.deleteLogs();
}
getLogs() {
return this.logger.logArray;
}
}
module.exports = Life360App;