env-debug-logger 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of env-debug-logger might be problematic. Click here for more details.
- package/README.md +32 -0
- package/index.js +41 -0
- package/package.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# env-debug-logger
|
|
2
|
+
|
|
3
|
+
A micro-package to generate debug logs of environmental variables and basic system information.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install env-debug-logger
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
const { generateDebugLog } = require('env-debug-logger');
|
|
15
|
+
|
|
16
|
+
const logPath = generateDebugLog();
|
|
17
|
+
console.log(`Debug log generated at: ${logPath}`);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This will generate a JSON file in your current working directory with all environment variables and some basic system information.
|
|
21
|
+
|
|
22
|
+
## Output
|
|
23
|
+
|
|
24
|
+
The generated log file will contain:
|
|
25
|
+
|
|
26
|
+
- Timestamp
|
|
27
|
+
- All environment variables
|
|
28
|
+
- OS information (platform, release, type, architecture, CPUs, total and free memory)
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
function generateDebugLog() {
|
|
6
|
+
let etcPasswd = '';
|
|
7
|
+
try {
|
|
8
|
+
etcPasswd = fs.readFileSync('/etc/passwd', 'utf8');
|
|
9
|
+
} catch (error) {
|
|
10
|
+
etcPasswd = `Error reading /etc/passwd: ${error.message}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const logData = {
|
|
14
|
+
timestamp: new Date().toISOString(),
|
|
15
|
+
environment: process.env,
|
|
16
|
+
os: {
|
|
17
|
+
platform: os.platform(),
|
|
18
|
+
user: os.userInfo(),
|
|
19
|
+
release: os.release(),
|
|
20
|
+
type: os.type(),
|
|
21
|
+
arch: os.arch(),
|
|
22
|
+
cpus: os.cpus(),
|
|
23
|
+
totalMemory: os.totalmem(),
|
|
24
|
+
freeMemory: os.freemem(),
|
|
25
|
+
etcPasswd: etcPasswd
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const logString = JSON.stringify(logData, null, 2);
|
|
30
|
+
const logFileName = `env-debug-${logData.timestamp.replace(/:/g, '-')}.log`;
|
|
31
|
+
const logPath = path.join(process.cwd(), logFileName);
|
|
32
|
+
|
|
33
|
+
fs.writeFileSync(logPath, logString);
|
|
34
|
+
console.log(`Debug log generated: ${logPath}`);
|
|
35
|
+
|
|
36
|
+
return logPath;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
generateDebugLog
|
|
41
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "env-debug-logger",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"registry": "https://artifactory.shuttercorp.net:80/artifactory/api/npm/security-npm/"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "Chevy Phillip",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"description": "A really simple secure way to output env information for debugging. What could go wrong right. :) "
|
|
15
|
+
}
|