{"_id":"1001tv-logger","_rev":"3-361fb75811aa73866fe8841a0981212f","name":"1001tv-logger","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"1001tv-logger","version":"1.0.0","keywords":["logger","winston","typescript","correlation-id"],"author":{"name":"1001.tv"},"license":"ISC","_id":"1001tv-logger@1.0.0","maintainers":[{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"}],"dist":{"shasum":"dd5bae9719545f5781fbeb85de46e825b3f8ac85","tarball":"https://registry.npmjs.org/1001tv-logger/-/1001tv-logger-1.0.0.tgz","fileCount":5,"integrity":"sha512-6Ipv6U3IHVRgbdH3H+1KzTQRmNr3eL7PqjIDd9vvS1peVS2/FCHCz8O2MALIQeGwSi16/Jac+t0b2bv/eXiHjA==","signatures":[{"sig":"MEUCIQCNYsLI5Q9gka4LD5IQxxKfB34CidyF2QBhbk2Xut7VZgIgOY308bOpMqnlMMGjQh3HD2BCFsx9nv30WR5wLLlSDUo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5601},"main":"dist/logger.js","types":"dist/logger.d.ts","scripts":{"build":"tsc"},"_npmUser":{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"},"_npmVersion":"10.8.1","description":"A customizable logger using Winston and CLS-Hooked for correlation IDs.","directories":{},"_nodeVersion":"20.16.0","dependencies":{"winston":"^3.14.2","cls-hooked":"^4.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.5.4","@types/node":"^22.5.1","@types/cls-hooked":"^4.3.8"},"_npmOperationalInternal":{"tmp":"tmp/1001tv-logger_1.0.0_1724885774878_0.8702122500447012","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"1001tv-logger","version":"1.0.1","keywords":["logger","winston","typescript","correlation-id"],"author":{"name":"1001.tv"},"license":"ISC","_id":"1001tv-logger@1.0.1","maintainers":[{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"}],"dist":{"shasum":"09a00cb3ec14e7c42878d39248135459d5e9ef38","tarball":"https://registry.npmjs.org/1001tv-logger/-/1001tv-logger-1.0.1.tgz","fileCount":5,"integrity":"sha512-3tTx0yLzZVbwdgQW+rdt0n3c9LlJClisSb/kKIUA/uV9u/4nGJw34bUDwylXuetPGFM/Vhk7nrSxraq7A7rTPg==","signatures":[{"sig":"MEYCIQC14MCgFeOejFNbPc0YOBZLI1gaGr5KlYXb6Skfc3GB2QIhAM7NKIEr0L/WFCN7rL6bmWqdmNtx+VnHYxKHv9Cdb/W8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5605},"main":"dist/logger.js","types":"dist/logger.d.ts","scripts":{"build":"tsc"},"_npmUser":{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"},"_npmVersion":"10.8.1","description":"A customizable logger using Winston and CLS-Hooked for correlation IDs.","directories":{},"_nodeVersion":"20.16.0","dependencies":{"winston":"^3.14.2","cls-hooked":"^4.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.5.4","@types/node":"^22.5.1","@types/cls-hooked":"^4.3.8"},"_npmOperationalInternal":{"tmp":"tmp/1001tv-logger_1.0.1_1724885832626_0.357226725334014","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"1001tv-logger","version":"1.0.2","keywords":["logger","winston","typescript","correlation-id"],"author":{"name":"1001.tv"},"license":"ISC","_id":"1001tv-logger@1.0.2","maintainers":[{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"}],"dist":{"shasum":"dbba79a2d97e57ea5b1783a924476293a60048e6","tarball":"https://registry.npmjs.org/1001tv-logger/-/1001tv-logger-1.0.2.tgz","fileCount":5,"integrity":"sha512-sMCZ9RATChPxFqIeCKDpVdByM4wzU6d/+lZ6om9r+zDP3AGPLMd8GLaYYXxUmWHgBPkM0SH4cP55uDTLu3ME3g==","signatures":[{"sig":"MEYCIQCGkc5vznZE0sqaBo4AjDPEiQv3GapIVpNxvSgoDf4M3AIhAMQ097V5enAPmIADYXcGa2++VefLu4nsJnpEyjZY0pY9","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5605},"main":"dist/logger.js","types":"dist/logger.d.ts","scripts":{"build":"tsc"},"_npmUser":{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"},"_npmVersion":"10.8.1","description":"A customizable logger using Winston and CLS-Hooked for correlation IDs.","directories":{},"_nodeVersion":"20.16.0","dependencies":{"winston":"^3.14.2","cls-hooked":"^4.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.5.4","@types/node":"^22.5.1","@types/cls-hooked":"^4.3.8"},"_npmOperationalInternal":{"tmp":"tmp/1001tv-logger_1.0.2_1724887332169_0.19301215105434233","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"1001tv-logger","version":"1.0.3","description":"A customizable logger using Winston and CLS-Hooked for correlation IDs.","main":"dist/logger.js","types":"dist/logger.d.ts","scripts":{"build":"tsc"},"keywords":["logger","winston","typescript","correlation-id"],"author":{"name":"1001.tv"},"license":"ISC","dependencies":{"cls-hooked":"^4.2.2","winston":"^3.14.2"},"devDependencies":{"@types/cls-hooked":"^4.3.8","@types/node":"^22.5.1","typescript":"^5.5.4"},"publishConfig":{"access":"public"},"_id":"1001tv-logger@1.0.3","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-jOF7wrKyOMGBIerMZ7TziqjjaGum8DZDNyzZO7GO368eNrCGE0ZHu+vYOWWdZjOgAgPpUbhV2zW6C5fgQW+4oA==","shasum":"62c929680e73dcb24362d827f5beee773f846e44","tarball":"https://registry.npmjs.org/1001tv-logger/-/1001tv-logger-1.0.3.tgz","fileCount":5,"unpackedSize":5605,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGIIokYaK8MJFJ9XgrcYg051Ba47crlgL4FIgZhdJnZrAiEAkQvFgyAM8n6N6ObGZHzfKwFaKORQly0xqk0n9Czy3Do="}]},"_npmUser":{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"},"directories":{},"maintainers":[{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/1001tv-logger_1.0.3_1724887571584_0.5845276587832704"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-28T22:56:14.783Z","modified":"2024-08-28T23:26:11.945Z","1.0.0":"2024-08-28T22:56:15.023Z","1.0.1":"2024-08-28T22:57:12.782Z","1.0.2":"2024-08-28T23:22:12.305Z","1.0.3":"2024-08-28T23:26:11.739Z"},"author":{"name":"1001.tv"},"license":"ISC","keywords":["logger","winston","typescript","correlation-id"],"description":"A customizable logger using Winston and CLS-Hooked for correlation IDs.","maintainers":[{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"}],"readme":"# 1001tv-logger\n\n**1001tv-logger** is a customizable logging library built on top of Winston with support for CLS-Hooked for correlation IDs. This library is designed for use across multiple TypeScript projects, providing structured logging with mandatory and optional metadata fields for 1001tv services.\n\n## Features\n\n- **Structured Logging**: Logs are formatted in JSON, making them easy to parse and analyze using log aggregation tools like AWS CloudWatch.\n\n- **Correlation IDs**: Automatically injects correlation IDs into logs from CLS-Hooked, ensuring that all logs from a single request are grouped together and making it easy to trace requests across distributed.\n\n- **Customizable Log Levels**: Supports custom log levels (error, warn, info).\n\n## Metadata\n1001-Logger requires certain fields if additional metadata is included in the log message. :\n\n**layer** (mandatory): Indicates the layer where the log is generated (e.g., 'main', 'service', 'controller', 'repository', 'middleware', 'other').\n**function** (mandatory): The name of the function where the log is printed.\nAny additional fields can be included as optional metadata (e.g., userId, errorCode).\n\n## Usage\n\n1- Basic Setup\nImport the logger into your project:\n\n```ts\nimport { logInfo, logError } from '1001-logger';\n```\n2- Logging Examples\n\n**Info Logging**\n```ts\nlogInfo('This is an informational message');\n\n// Or\nlogInfo('This is an informational message', {\n  layer: 'service', // Mandatory metadata\n  function: 'fetchData', // Mandatory metadata\n  userId: '1234' // Optional metadata\n});\n```\n**Warn Logging**\n\n```ts\nlogWarn('This is a warning message');\n\n// Or\nlogWarn('This is a warning message', {\n  layer: 'controller', // Mandatory\n    function: 'handleRequest', // Mandatory metadata\n    userId: '5678' // Optional metadata\n});\n```\n\n**Error Logging**\n\n```ts\nlogError('This is an error message');\n\n// Or\nlogError('This is an error message', {\n  layer: 'controller', // Mandatory metadata\n  function: 'handleRequest', // Mandatory metadata\n  errorCode: 'ERR123', // Optional metadata\n  userId: '5678' // Optional metadata\n});\n```\n\n## Correlation IDs\nThe logger automatically injects a correlationId into every log message if it is available in the CLS-Hooked namespace (auth-middleware-namespace). This is useful for tracking a single request across various services and layers.\n\nExample:\n\n```ts\n// Ensure a correlation ID is set up earlier in the middleware or service\nimport { Request, Response, NextFunction } from 'express';\nimport { createNamespace } from 'cls-hooked';\n\nconst session = createNamespace('auth-middleware-namespace');\n\nexport function storeCorrelationIdMiddleware(req: Request, res: Response, next: NextFunction) {\n    session.run(() => {\n        session.set('correlationId', req.headers['x-correlation-id']);\n        next();\n    });\n}\n```","readmeFilename":"README.md"}