{"_id":"@bwisemedia/njs-logger","_rev":"6-5d8479922c4cd9ee4e8c73e831c6196f","name":"@bwisemedia/njs-logger","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.1":{"name":"@bwisemedia/njs-logger","version":"0.1.1","keywords":["logger","winston","esm","cjs"],"author":{"name":"Giancarlo Diana @ bwisemedia"},"license":"MIT","_id":"@bwisemedia/njs-logger@0.1.1","maintainers":[{"name":"gdbwm","email":"giancarlo@bwisemedia.com"}],"homepage":"https://github.com/bwisemedia/njs-logger#readme","bugs":{"url":"https://github.com/bwisemedia/njs-logger/issues"},"dist":{"shasum":"e43ad26ce839921d412e0f165895a932ef7cdeb4","tarball":"https://registry.npmjs.org/@bwisemedia/njs-logger/-/njs-logger-0.1.1.tgz","fileCount":6,"integrity":"sha512-SgHqGTgOjdeBGfbvvRPznVP2PksGdBxRb317qNX66uzFRum+4ZCeYOsOsQCg3ql0HS0sRj8iw+J+J2xTWP0+Fg==","signatures":[{"sig":"MEUCIQCOXKOY5DB7lEQgD9tyoQ6Jm73Zyt9DAWUPQVJFW6pYOQIgfEZYnR3ADJF1BhmvrsutGFx09zOSK4cyu0JicUKJ0N0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16891},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"f20a69a30b9e25f90d46e47ef3fa2a1e540a9d64","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch","build":"tsup src/index.ts --format esm,cjs --dts --clean","prepublishOnly":"npm run build"},"_npmUser":{"name":"gdbwm","email":"giancarlo@bwisemedia.com"},"repository":{"url":"git+https://github.com/bwisemedia/njs-logger.git","type":"git"},"_npmVersion":"10.9.0","description":"Winston-based logger with TCP/HTTP transports (ESM + CJS).","directories":{},"_nodeVersion":"22.12.0","dependencies":{"axios":"^1.7.7","dotenv":"^16.4.5","winston":"^3.13.0","winston-transport":"^4.8.0","@bwisemedia/njs-logger":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.2"},"_npmOperationalInternal":{"tmp":"tmp/njs-logger_0.1.1_1757955892375_0.5876551512801198","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@bwisemedia/njs-logger","version":"0.1.2","keywords":["logger","winston","esm","cjs"],"author":{"name":"Giancarlo Diana @ bwisemedia"},"license":"MIT","_id":"@bwisemedia/njs-logger@0.1.2","maintainers":[{"name":"gdbwm","email":"giancarlo@bwisemedia.com"}],"homepage":"https://github.com/bwisemedia/njs-logger#readme","bugs":{"url":"https://github.com/bwisemedia/njs-logger/issues"},"dist":{"shasum":"eec1a0c314c730f5f92a281a62ddbe149510c9a4","tarball":"https://registry.npmjs.org/@bwisemedia/njs-logger/-/njs-logger-0.1.2.tgz","fileCount":6,"integrity":"sha512-5axRqXZcQ/9tD+ZE0VyJgnORgbQhf1vNUaWcmZuRKyWSMIzFj8j3ytsA2c7Stfh/Kcmrvq1DKptquqexNWinMA==","signatures":[{"sig":"MEUCIQDOOuyWcd+xajkZDyoau1spq5EJA+DS4W4gxVzEd41oWwIgCccZeD+EzkgF+fGfs4Wy2q3yosHJPqU8PboQ4D9jcOk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16891},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"f20a69a30b9e25f90d46e47ef3fa2a1e540a9d64","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch","build":"tsup src/index.ts --format esm,cjs --dts --clean","prepublishOnly":"npm run build"},"_npmUser":{"name":"gdbwm","email":"giancarlo@bwisemedia.com"},"repository":{"url":"git+https://github.com/bwisemedia/njs-logger.git","type":"git"},"_npmVersion":"10.9.0","description":"Winston-based logger with TCP/HTTP transports (ESM + CJS).","directories":{},"_nodeVersion":"22.12.0","dependencies":{"axios":"^1.7.7","dotenv":"^16.4.5","winston":"^3.13.0","winston-transport":"^4.8.0","@bwisemedia/njs-logger":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.2"},"_npmOperationalInternal":{"tmp":"tmp/njs-logger_0.1.2_1757956186894_0.18250455082808958","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@bwisemedia/njs-logger","version":"0.2.0","keywords":["logger","winston","esm","cjs"],"author":{"name":"Giancarlo Diana @ bwisemedia"},"license":"MIT","_id":"@bwisemedia/njs-logger@0.2.0","maintainers":[{"name":"gdbwm","email":"giancarlo@bwisemedia.com"}],"homepage":"https://github.com/bwisemedia/njs-logger#readme","bugs":{"url":"https://github.com/bwisemedia/njs-logger/issues"},"dist":{"shasum":"033dda4ff36e392686f999d71599ab1b8fd03c9f","tarball":"https://registry.npmjs.org/@bwisemedia/njs-logger/-/njs-logger-0.2.0.tgz","fileCount":6,"integrity":"sha512-ijNiUkRiq+ik/MYjEaJ4fUeW4hui2yhuqwMFMhOLKrdlUN7xeyvssXCRrpWZDe7h2jftRwbxPJ0iGkzHWNY5iQ==","signatures":[{"sig":"MEUCIF0BLFr7hIyPdrVu81d+Ziffe+oZJHFq2VP/ksd9Y/UuAiEAh9yvxnBTQVa1ksT2sB1hbHukEZfLHl1b5WeeG+KUpXA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21558},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"b827a54aa2320def3535cfc212015cc22b7f4816","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch","build":"tsup src/index.ts --format esm,cjs --dts --clean","prepublishOnly":"npm run build"},"_npmUser":{"name":"gdbwm","email":"giancarlo@bwisemedia.com"},"repository":{"url":"git+https://github.com/bwisemedia/njs-logger.git","type":"git"},"_npmVersion":"10.9.0","description":"Winston-based logger with TCP/HTTP transports (ESM + CJS).","directories":{},"_nodeVersion":"22.12.0","dependencies":{"axios":"^1.7.7","dotenv":"^16.4.5","winston":"^3.13.0","winston-transport":"^4.8.0","@bwisemedia/njs-logger":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.2"},"_npmOperationalInternal":{"tmp":"tmp/njs-logger_0.2.0_1774281179970_0.7597361073548474","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@bwisemedia/njs-logger","version":"0.2.1","description":"Winston-based logger with TCP/HTTP transports (ESM + CJS).","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"scripts":{"build":"tsup src/index.ts --format esm,cjs --dts --clean","prepublishOnly":"npm run build","dev":"tsup src/index.ts --format esm,cjs --dts --watch"},"keywords":["logger","winston","esm","cjs"],"author":{"name":"Giancarlo Diana @ bwisemedia"},"license":"MIT","engines":{"node":">=18"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/bwisemedia/njs-logger.git"},"bugs":{"url":"https://github.com/bwisemedia/njs-logger/issues"},"homepage":"https://github.com/bwisemedia/njs-logger#readme","dependencies":{"@bwisemedia/njs-logger":"^0.1.0","axios":"^1.7.7","dotenv":"^16.4.5","winston":"^3.13.0","winston-transport":"^4.8.0"},"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.2"},"_id":"@bwisemedia/njs-logger@0.2.1","gitHead":"b827a54aa2320def3535cfc212015cc22b7f4816","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-NZJREJQ4ipDMo/bB4mbA+T5i/sNbQ++tkM/+yxl4PzkUeF6GjTvZNKupOqGoHn9lSshJjurRxaBxSXyPCFEUUQ==","shasum":"7e32ddb507d8d75bc982ddc54806eb84384bbbbd","tarball":"https://registry.npmjs.org/@bwisemedia/njs-logger/-/njs-logger-0.2.1.tgz","fileCount":6,"unpackedSize":21558,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICBzIl0IKQhDaKdGsaeeypET8sx7nrUR8/PcA2DPl2KbAiACj2HFXgbft+TUG1LGLzGwJ3daDiBmNo2rCwqAGsCDgw=="}]},"_npmUser":{"name":"gdbwm","email":"giancarlo@bwisemedia.com"},"directories":{},"maintainers":[{"name":"gdbwm","email":"giancarlo@bwisemedia.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/njs-logger_0.2.1_1774282549752_0.8228516785803976"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-15T17:04:52.294Z","modified":"2026-03-23T16:15:50.046Z","0.1.0":"2025-09-15T17:01:47.572Z","0.1.1":"2025-09-15T17:04:52.534Z","0.1.2":"2025-09-15T17:09:47.074Z","0.2.0":"2026-03-23T15:53:00.112Z","0.2.1":"2026-03-23T16:15:49.910Z"},"bugs":{"url":"https://github.com/bwisemedia/njs-logger/issues"},"author":{"name":"Giancarlo Diana @ bwisemedia"},"license":"MIT","homepage":"https://github.com/bwisemedia/njs-logger#readme","keywords":["logger","winston","esm","cjs"],"repository":{"type":"git","url":"git+https://github.com/bwisemedia/njs-logger.git"},"description":"Winston-based logger with TCP/HTTP transports (ESM + CJS).","maintainers":[{"name":"gdbwm","email":"giancarlo@bwisemedia.com"}],"readme":"# @bwisemedia/njs-logger\n\nA Winston-based logger library for Node.js applications, with support for:\n\n- local output to file + console;\n- remote forwarding via TCP or HTTP;\n- dual-package distribution for ESM and CommonJS.\n\nThe exported logger behaves like `console.log`: it accepts multiple arguments and automatically serializes strings, objects, and errors.\n\n## Overview\n\nThe package exports a preconfigured singleton `logger`:\n\n- input: calls to standard logger methods (`info`, `warn`, `error`, `debug`, etc.);\n- local output:\n  - `logs/logs/combined.log` (all levels),\n  - `logs/logs/error.log` (errors only),\n  - configurable console output (`standard` or JSON);\n- optional remote output:\n  - TCP (`LOGGER_TRANSPORT_TYPE=tcp`),\n  - HTTP (`LOGGER_TRANSPORT_TYPE=http`).\n\nConfiguration is environment-variable driven (`dotenv` is loaded automatically).\n\n## Requirements\n\n- Node.js `>= 18`\n- npm (or any compatible package manager)\n\n## Installation\n\n```bash\nnpm install @bwisemedia/njs-logger\n```\n\n## Usage\n\n### ESM\n\n```js\nimport logger from \"@bwisemedia/njs-logger\";\n\nlogger.info(\"Server started\", { port: 3000 });\nlogger.warn(\"Incomplete configuration\", { key: \"SMTP_HOST\" });\nlogger.error(\"Application error\", new Error(\"DB timeout\"));\n```\n\n### CommonJS\n\n```js\nconst logger = require(\"@bwisemedia/njs-logger\").default;\n\nlogger.debug(\"Debug payload\", { userId: 42, action: \"login\" });\n```\n\n## Environment Variables\n\nThe variables below are the ones actually read by the code.\n\n### General\n\n| Variable | Default | Description |\n| --- | --- | --- |\n| `APP_NAME` | `unknown-app` | Application name added to log payloads. |\n| `APP_ENV` | `development` | Environment (`development`, `staging`, `production`, etc.). |\n| `LOGGER_MIN_LEVEL` | `info` | Global minimum Winston logger level. |\n| `STANDARD_OUTPUT` | `standard` | Standard output format: `standard` (human-readable) or `json` (structured). |\n\n### Remote Forwarding Controls\n\n| Variable | Default | Description |\n| --- | --- | --- |\n| `LOGGER_SEND_TO_ELK` | `true` | If `true`, enables adding a remote transport. |\n| `LOGGER_TRANSPORT_TYPE` | _(none)_ | Remote transport type: `tcp` or `http`. |\n| `LOGGER_SEND_TO_ELK_MIN_LEVEL` | `error` | Minimum level for the remote transport. |\n\n### Transport TCP\n\n| Variable | Default | Description |\n| --- | --- | --- |\n| `TCP_LOGGER_HOST` | `localhost` | TCP collector host. |\n| `TCP_LOGGER_PORT` | `5000` | TCP collector port. |\n\n### Transport HTTP\n\n| Variable | Default | Description |\n| --- | --- | --- |\n| `HTTP_LOGGER_ENDPOINT` | `http://localhost:8080` | HTTP endpoint that receives logs. |\n| `HTTP_LOGGER_TOKEN` | `\"\"` | Bearer token used in the `Authorization` header. |\n\n## Configuration Examples\n\n### Local Logs Only (file + console)\n\n```bash\nAPP_NAME=my-service\nAPP_ENV=development\nLOGGER_MIN_LEVEL=info\nSTANDARD_OUTPUT=standard\nLOGGER_SEND_TO_ELK=false\n```\n\n### Docker-Friendly Standard Output (JSON)\n\nUse this when you want structured logs in `docker logs`:\n\n```bash\nAPP_NAME=my-service\nAPP_ENV=production\nLOGGER_MIN_LEVEL=info\nSTANDARD_OUTPUT=json\nLOGGER_SEND_TO_ELK=false\n```\n\n### Remote Forwarding via TCP\n\n```bash\nAPP_NAME=my-service\nAPP_ENV=production\nLOGGER_SEND_TO_ELK=true\nLOGGER_TRANSPORT_TYPE=tcp\nLOGGER_SEND_TO_ELK_MIN_LEVEL=error\nTCP_LOGGER_HOST=logs.internal\nTCP_LOGGER_PORT=9000\n```\n\n### Remote Forwarding via HTTP\n\n```bash\nAPP_NAME=my-service\nAPP_ENV=production\nLOGGER_SEND_TO_ELK=true\nLOGGER_TRANSPORT_TYPE=http\nLOGGER_SEND_TO_ELK_MIN_LEVEL=warn\nHTTP_LOGGER_ENDPOINT=https://logserver.example.com/ingest\nHTTP_LOGGER_TOKEN=your-secret-token\n```\n\n## Runtime Behavior\n\n- Logger methods (`error`, `warn`, `info`, `http`, `verbose`, `debug`, `silly`) are wrapped to support multiple arguments.\n- Each argument is converted as follows:\n  - `string` -> unchanged string;\n  - `Error` -> `stack` (or `message`);\n  - other objects -> `JSON.stringify` (fallback to `String()` if needed).\n- JSON payloads include application metadata (`app`, `environment`) and timestamps.\n- `STANDARD_OUTPUT=json` switches only the standard console/stdout transport to JSON, useful for containerized workloads.\n- The TCP transport keeps a local buffer while disconnected and flushes buffered messages after reconnecting.\n\n## Local Package Development\n\n```bash\nnpm install\nnpm run build\n```\n\nBuild output:\n\n- `dist/index.js` (ESM)\n- `dist/index.cjs` (CJS)\n- `dist/index.d.ts` (TypeScript types)\n\nWatch mode:\n\n```bash\nnpm run dev\n```\n\nTest with `npm link`:\n\n```bash\nnpm link\n```\n\nIn a consumer project:\n\n```bash\nnpm link @bwisemedia/njs-logger\n```\n\n## Docker Test (Mounted Project)\n\nUse the test Dockerfile to run the logger in a container while mounting your local project.\nThis is useful to verify structured stdout logs with `docker logs`.\n\nBuild the test image:\n\n```bash\ndocker build -f Dockerfile.test -t njs-logger-test .\n```\n\nRun with JSON standard output (recommended for container logging validation):\n\n```bash\ndocker run --rm \\\n  -v \"$(pwd)\":/workspace \\\n  -e STANDARD_OUTPUT=json \\\n  -e APP_NAME=my-service \\\n  -e APP_ENV=production \\\n  -e LOGGER_SEND_TO_ELK=false \\\n  njs-logger-test\n```\n\nRun with human-readable standard output:\n\n```bash\ndocker run --rm \\\n  -v \"$(pwd)\":/workspace \\\n  -e STANDARD_OUTPUT=standard \\\n  -e LOGGER_SEND_TO_ELK=false \\\n  njs-logger-test\n```\n\nOptional quick test (shorter run):\n\n```bash\ndocker run --rm \\\n  -v \"$(pwd)\":/workspace \\\n  -e STANDARD_OUTPUT=json \\\n  -e LOGGER_SEND_TO_ELK=false \\\n  -e LOG_MESSAGES=5 \\\n  -e LOG_INTERVAL_MS=500 \\\n  njs-logger-test\n```\n\n## Publishing\n\nThe package automatically runs the build in `prepublishOnly`.\n\nTypical flow:\n\n```bash\nnpm version patch\ngit push --follow-tags\n```\n\n## Operational Notes\n\n- The repository includes `.env.example`; use it as a baseline and keep it aligned with the effective variables above.\n- If `LOGGER_SEND_TO_ELK=true` but `LOGGER_TRANSPORT_TYPE` is not set to `tcp` or `http`, only local transports stay active.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}