Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        


JSON-ACTIVITY-LOG


GitHub top language


Made by


Repository size


GitHub last commit

### ๐Ÿ“– 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).