|
1 | | -const os = require('os'); |
2 | | -const packageFile = require('../../package.json'); |
3 | | - |
4 | | -const prefixZero = number => (number < 10 ? '0' + number : number); |
5 | | - |
6 | | -const maxClock = cpus => { |
7 | | - return cpus.reduce((highestClock, cpu) => Math.max(highestClock, cpu.speed), 0); |
8 | | -}; |
9 | | - |
10 | | -const toTime = number => { |
11 | | - return Math.floor(number / 3600) + ':' + prefixZero(parseInt((number / 3600 - Math.floor(number / 3600)) * 60)); |
12 | | -}; |
13 | | - |
14 | | -const getPluginVersion = () => packageFile.version; |
15 | | - |
16 | | -const getSystemInfo = appVersion => { |
17 | | - return ( |
18 | | - '' + |
19 | | - `Date: ${new Date()}` + |
20 | | - '\n' + |
21 | | - `Application version: ${appVersion}` + |
22 | | - '\n' + |
23 | | - `Plugin version: ${getPluginVersion()}` + |
24 | | - '\n\n' + |
25 | | - `System information:` + |
26 | | - '\n' + |
27 | | - ` Hostname: ${os.hostname()}` + |
28 | | - '\n' + |
29 | | - ` Platform: ${os.platform()} ${os.arch()}` + |
30 | | - '\n' + |
31 | | - ` Release: ${os.release()}` + |
32 | | - '\n' + |
33 | | - ` Uptime: ${toTime(os.uptime())}` + |
34 | | - '\n' + |
35 | | - ` Total RAM: ${(os.totalmem() / 1073741824).toFixed(2)} GB` + |
36 | | - '\n' + |
37 | | - ` CPU Model: ${os.cpus()[0].model}` + |
38 | | - '\n' + |
39 | | - ` CPU Clock: ${maxClock(os.cpus())} MHZ` + |
40 | | - '\n' + |
41 | | - ` CPU Cores: ${os.cpus().length} cores` + |
42 | | - '\n\n' |
43 | | - ); |
44 | | -}; |
45 | | - |
46 | 1 | const logInfo = (step, connectionInfo, logger) => { |
47 | 2 | logger.clear(); |
48 | | - logger.log('info', getSystemInfo(connectionInfo.appVersion), step); |
49 | 3 | logger.log('info', connectionInfo, 'connectionInfo', connectionInfo.hiddenKeys); |
50 | 4 | }; |
51 | 5 |
|
|
0 commit comments