Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/damartripamungkas/json-activity-log
๐๏ธ Writes results and logs in json file format
https://github.com/damartripamungkas/json-activity-log
backend javascript json json-activity json-activity-log json-log log-json nodejs typescript
Last synced: about 1 month ago
JSON representation
๐๏ธ Writes results and logs in json file format
- Host: GitHub
- URL: https://github.com/damartripamungkas/json-activity-log
- Owner: damartripamungkas
- License: mit
- Created: 2024-06-05T16:49:43.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-08-19T11:41:15.000Z (5 months ago)
- Last Synced: 2024-11-01T11:47:50.271Z (2 months ago)
- Topics: backend, javascript, json, json-activity, json-activity-log, json-log, log-json, nodejs, typescript
- Language: TypeScript
- Homepage: https://npmjs.com/package/json-activity-log
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
JSON-ACTIVITY-LOG### ๐ Description :
This package was created for those of you who want a combination of logging and results in JSON style and will be written to a file.
### ๐ป Step to install :
```
npm install json-activity-log
```### โ๏ธ Example :
see full [here](./test/test.js)
`code javascript`
```javascript
const { join } = require("node:path")
const { jsonActivityLog } = require("json-activity-log")const test1 = async () => {
const stepAllKey = [`[1] setup_code_expressjs", "[2] end`]
const [step1, step2] = stepAllKey
const pathFileSave = join(__dirname, `test.json`)const init = jsonActivityLog(pathFileSave, `run_web_server`, stepAllKey, true)
await init.writeLogInfo(step1, `write simple code webserver`)
await init.writeResult(step1, { host: `localhost`, port: "3000" })
await init.writeResult(step2, { status: `success` })
}const test2 = async () => {
const stepAllKey = [`[1] init_telegraf_constructor`, `[2] end`]
const [step1, step2] = stepAllKey
const pathFileSave = join(__dirname, `test.json`)const init = jsonActivityLog(pathFileSave, `run_telegram_bot`, stepAllKey, true)
await init.writeLogInfo(step1, `write simple code telegraf initialized`)
await init.writeResult(step1, { status: `success` })
await init.writeResult(step2, { status: `success` })
}const run = async () => {
await test1()
await test2()
}run()
````result in json file`
```json
{
"run_web_server": {
"[1] setup_code_expressjs": {
"result": {
"host": "localhost",
"port": "3000"
},
"log": {
"[2024-06-05 23:40:42:513] [INFO]": "write simple code webserver"
}
},
"[2] end": {
"result": {
"status": "success"
},
"log": {}
}
},
"run_telegram_bot": {
"[1] init_telegraf_constructor": {
"result": {
"status": "success"
},
"log": {
"[2024-06-05 23:40:42:537] [INFO]": "write simple code telegraf initialized"
}
},
"[2] end": {
"result": {
"status": "success"
},
"log": {}
}
}
}
```### ๐งพ Pre-Requisistes :
```
node.js
```### ๐ License :
Licensed under the [MIT License](./LICENSE).