{"_id":"1001-logger","_rev":"4-44f3d48faba8d65b28b5f5b946b3d8bf","name":"1001-logger","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"1001-logger","version":"1.0.0","keywords":["logger","winston","typescript","correlation-id"],"author":{"name":"1001.tv"},"license":"ISC","_id":"1001-logger@1.0.0","maintainers":[{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"}],"dist":{"shasum":"7a6457ccfccc49ae115e1237b8dcba1f07357f4e","tarball":"https://registry.npmjs.org/1001-logger/-/1001-logger-1.0.0.tgz","fileCount":3,"integrity":"sha512-GwnilPGFMe+99Y380XMx3SzRtGus64yEkv8NCAwwmy76+rdcNU1BR5zU6xL8qt+OFnFOGr9aJwsIxO97XeZUnA==","signatures":[{"sig":"MEUCIQCc159IaSW5Mva/C+Fh7nkBxdOp/F6ZjAx/5xpbrXHZJwIgA9QU+vS7Yq5I8ZrrwUwlKoU5iH9UmbdKrza7ZSoN0oc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1966},"main":"dist/logger.js","types":"dist/types.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"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.5.4","@types/node":"^22.5.1","@types/cls-hooked":"^4.3.8"},"_npmOperationalInternal":{"tmp":"tmp/1001-logger_1.0.0_1724880158098_0.24351298555590017","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"1001-logger","version":"1.0.1","keywords":["logger","winston","typescript","correlation-id"],"author":{"name":"1001.tv"},"license":"ISC","_id":"1001-logger@1.0.1","maintainers":[{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"}],"dist":{"shasum":"ccf65f7011ef96f3051a2e706d68c00b466f1246","tarball":"https://registry.npmjs.org/1001-logger/-/1001-logger-1.0.1.tgz","fileCount":4,"integrity":"sha512-qNonoRR1WdwZgghlMSbcis9l8jpMPN0tsyTV1OpsfxDe/FIub1j6+gvZpvRFMQkQdcalJKdyTRBCDKI7CpMblw==","signatures":[{"sig":"MEUCICUIinhxDTtgruJz2uMPujqWontopDgrU6DGZRdfaMmlAiEAto7bflhVpfPraGeEKSM0/wZxBMCAcGDvJ/NjgmxND0o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4930},"main":"dist/logger.js","types":"dist/types.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"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.5.4","@types/node":"^22.5.1","@types/cls-hooked":"^4.3.8"},"_npmOperationalInternal":{"tmp":"tmp/1001-logger_1.0.1_1724881271794_0.5569338617657491","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"1001-logger","version":"1.0.2","keywords":["logger","winston","typescript","correlation-id"],"author":{"name":"1001.tv"},"license":"ISC","_id":"1001-logger@1.0.2","maintainers":[{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"}],"dist":{"shasum":"f954069ca1fa66929b33cd71b8a54633fcf766db","tarball":"https://registry.npmjs.org/1001-logger/-/1001-logger-1.0.2.tgz","fileCount":4,"integrity":"sha512-8onFaY+usM5YZaJ3OEsxNF27hVKg6U2XArwJc4N0rqCtmN+z49nt4sqrf2AZg8bVFxziHnuWkBgVbw6csPBZYg==","signatures":[{"sig":"MEUCIQDeXgpfVP6reR9h+uaTopgNhyi8rQ2ztQDCkrGLSzrv8AIgX9eg0ixe4RGsQx0tTThiUV4SXPKo8WlUttsGVLX2DMU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4929},"main":"dist/logger.js","types":"dist/types.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"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.5.4","@types/node":"^22.5.1","@types/cls-hooked":"^4.3.8"},"_npmOperationalInternal":{"tmp":"tmp/1001-logger_1.0.2_1724881318835_0.201011211121624","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"1001-logger","version":"1.0.3","keywords":["logger","winston","typescript","correlation-id"],"author":{"name":"1001.tv"},"license":"ISC","_id":"1001-logger@1.0.3","maintainers":[{"name":"nurettin1001","email":"nurettin.fayad@1001.tv"}],"dist":{"shasum":"fbde1c963d432c55b81aef80927c90eef79dacab","tarball":"https://registry.npmjs.org/1001-logger/-/1001-logger-1.0.3.tgz","fileCount":5,"integrity":"sha512-VURguSC2K+3SJkSfguBX0lbG1nIWvak29ixRVbfkulVasCQaOHTLnvQCC/3FsI9vRLHRL66jjn6ZwYvEBPwaeA==","signatures":[{"sig":"MEYCIQDI/9UG326qrmTRL2KB3hfxv6SWuN7gjZrM1KhDr6/QFgIhAJC6U+HOXlUc5ncyARrr881R/KUC65GwB1lWmR75Hyxy","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5549},"main":"dist/logger.js","types":"dist/types.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"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.5.4","@types/node":"^22.5.1","@types/cls-hooked":"^4.3.8"},"_npmOperationalInternal":{"tmp":"tmp/1001-logger_1.0.3_1724881944843_0.7504352981545468","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"1001-logger","version":"1.0.4","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"},"_id":"1001-logger@1.0.4","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-exlKi9KxgCUB5/GQItMuxuPPAduMnSwRGeER7PXra8RGISvIXwuBNty/M7sd5Uk+no0SBoyQFZMQkQlfWoLHDA==","shasum":"79b148367a69fb2e12da94b2021cc734e3728b80","tarball":"https://registry.npmjs.org/1001-logger/-/1001-logger-1.0.4.tgz","fileCount":5,"unpackedSize":5550,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDPz5aLn1J0ATYoY3jC9PeFlrMggPO1NlgHONNrkWmcvAiBhV+BFxiHCmfIP8FjSPLMtf9/EGkVarRJUyGClc4Lf0w=="}]},"_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/1001-logger_1.0.4_1724882187381_0.08702233864109421"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-28T21:22:37.973Z","modified":"2024-08-28T21:56:27.742Z","1.0.0":"2024-08-28T21:22:38.304Z","1.0.1":"2024-08-28T21:41:11.980Z","1.0.2":"2024-08-28T21:41:59.018Z","1.0.3":"2024-08-28T21:52:25.011Z","1.0.4":"2024-08-28T21:56:27.559Z"},"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":"# 1001-Logger\n\n**1001-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"}