{"_id":"@alexandru.g/cloudwatch-custom-logger","_rev":"5-1d540510bf146e35c34cacb1f85c4b5e","name":"@alexandru.g/cloudwatch-custom-logger","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@alexandru.g/cloudwatch-custom-logger","version":"1.0.0","keywords":[],"author":{"name":"Alexandru Gurita"},"license":"MIT","_id":"@alexandru.g/cloudwatch-custom-logger@1.0.0","maintainers":[{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"}],"dist":{"shasum":"0a099feab4aefd84d7511e4c1666c54b9f2ab1f1","tarball":"https://registry.npmjs.org/@alexandru.g/cloudwatch-custom-logger/-/cloudwatch-custom-logger-1.0.0.tgz","fileCount":6,"integrity":"sha512-GzxLSS0PBxZ17pwwfAQZGsRrQNkWZVzNk9LXb0zfWQINrR7LEnP8l2h+koa+cFH94QRfwuhvv8qmPrFWlDkOfw==","signatures":[{"sig":"MEUCICOlwUHn6xsi/VAD/IMk5NXLCU36qOyt1XnSsNWtmNSsAiEA2Du8ijc65N0HtSnP+focy47s+DhxKah4kjNpUrRAW6o=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6240},"main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"},"_npmVersion":"10.8.2","description":"Simple AWS CloudWatch logger for Node.js using AWS SDK v3","directories":{},"_nodeVersion":"20.19.4","dependencies":{"@aws-sdk/client-cloudwatch-logs":"^3.906.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cloudwatch-custom-logger_1.0.0_1760012796521_0.4689993426222385","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@alexandru.g/cloudwatch-custom-logger","version":"1.0.1","keywords":[],"author":{"name":"Alexandru Gurita"},"license":"MIT","_id":"@alexandru.g/cloudwatch-custom-logger@1.0.1","maintainers":[{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"}],"dist":{"shasum":"666b0c885b1b537b1f78a80c1a881a0251e15069","tarball":"https://registry.npmjs.org/@alexandru.g/cloudwatch-custom-logger/-/cloudwatch-custom-logger-1.0.1.tgz","fileCount":7,"integrity":"sha512-U3db6Lj3w7vqymHeX6XRKTwTvVe/hxv+gV7c5lTARIau6l5cGdxG4gtO7vPod0TL/o5RxxSe5WwTso56NLHRdQ==","signatures":[{"sig":"MEQCIAcpYiRaU0dtfGdt1NMs72aJQfHFXpJSf0PqE+5Y6RgwAiAku+WblNvBxHbGbf9TVcNxO6RKBWALDI5eAjReL0ApeA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10589},"main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"},"_npmVersion":"10.8.2","description":"Simple AWS CloudWatch logger for Node.js using AWS SDK v3","directories":{},"_nodeVersion":"20.19.4","dependencies":{"@aws-sdk/client-cloudwatch-logs":"^3.906.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cloudwatch-custom-logger_1.0.1_1760013424595_0.5742457992911103","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@alexandru.g/cloudwatch-custom-logger","version":"1.0.2","keywords":[],"author":{"name":"Alexandru Gurita"},"license":"MIT","_id":"@alexandru.g/cloudwatch-custom-logger@1.0.2","maintainers":[{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"}],"dist":{"shasum":"134019338342be2263b4f9ee7ca117bd40f7ec84","tarball":"https://registry.npmjs.org/@alexandru.g/cloudwatch-custom-logger/-/cloudwatch-custom-logger-1.0.2.tgz","fileCount":7,"integrity":"sha512-RhSQmTOzjAodhH94Zd7GI7rKLFjpPk8oqD7RghtEr2nAL4xWGuzMRNg4Oevy/5tWm2dsN7swhsr4bMER3u5+6w==","signatures":[{"sig":"MEUCIGIEurrWmK1tOeid6yvVZ0f69G2lU0VZO0lrITAsoHAPAiEA3FvZ83vd8c/pabynrWTkt2sG0Ng2d0s+jLiVVXOWNq4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10454},"main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"},"_npmVersion":"10.8.2","description":"Simple AWS CloudWatch logger for Node.js using AWS SDK v3","directories":{},"_nodeVersion":"20.19.4","dependencies":{"@aws-sdk/client-cloudwatch-logs":"^3.906.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cloudwatch-custom-logger_1.0.2_1760013451487_0.9590750301047144","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@alexandru.g/cloudwatch-custom-logger","version":"1.0.3","keywords":[],"author":{"name":"Alexandru Gurita"},"license":"MIT","_id":"@alexandru.g/cloudwatch-custom-logger@1.0.3","maintainers":[{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"}],"dist":{"shasum":"2f8843e039075f58fdb82278649efad0156458a8","tarball":"https://registry.npmjs.org/@alexandru.g/cloudwatch-custom-logger/-/cloudwatch-custom-logger-1.0.3.tgz","fileCount":7,"integrity":"sha512-ioeaI8HA6VnSEy5yJsXTvBrJqmr0tMkt33edHVtjzb0sVWpkqjjr3pa1zVZ3v74X7yG0aFd2z/H4yL6mrSiPnQ==","signatures":[{"sig":"MEUCIQCe51nRUOLflGX2msOKFkUNqt7o8qQmWWfydpBum9ImlwIgSsu+tqRSKzbcxPYcDS6nZvhpGv+KPEg47CQYUBIk5j8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10224},"main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"},"_npmVersion":"10.8.2","description":"Simple AWS CloudWatch logger for Node.js using AWS SDK v3","directories":{},"_nodeVersion":"20.19.4","dependencies":{"@aws-sdk/client-cloudwatch-logs":"^3.906.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cloudwatch-custom-logger_1.0.3_1760013551348_0.9079994141408072","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@alexandru.g/cloudwatch-custom-logger","version":"1.0.4","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":{"name":"Alexandru Gurita"},"license":"MIT","description":"Simple AWS CloudWatch logger for Node.js using AWS SDK v3","publishConfig":{"access":"public"},"dependencies":{"@aws-sdk/client-cloudwatch-logs":"^3.906.0"},"type":"module","_id":"@alexandru.g/cloudwatch-custom-logger@1.0.4","_nodeVersion":"20.19.4","_npmVersion":"10.8.2","dist":{"integrity":"sha512-mISE5WF+lSlCuW5iCjevjhM7BocF9ne7HG+797KOA3kE3vcuZhB3LcQyqJpeRDz8GXpD6/aFF52i9RZXNLcn+Q==","shasum":"5efec10ae8ad577c6dff30459ef383de757792ee","tarball":"https://registry.npmjs.org/@alexandru.g/cloudwatch-custom-logger/-/cloudwatch-custom-logger-1.0.4.tgz","fileCount":7,"unpackedSize":10226,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEkFB6ShZabDmLKFUMhqQUcJgDG3kNmzRzR9mEPiIjUnAiEAutwgvzIZMPSmSm0dwURA1HHTyXey6v4tCTRBLgnwzug="}]},"_npmUser":{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"},"directories":{},"maintainers":[{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cloudwatch-custom-logger_1.0.4_1760019686086_0.889568914191978"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-09T12:26:36.395Z","modified":"2025-10-09T14:21:26.486Z","1.0.0":"2025-10-09T12:26:36.690Z","1.0.1":"2025-10-09T12:37:04.769Z","1.0.2":"2025-10-09T12:37:31.668Z","1.0.3":"2025-10-09T12:39:11.531Z","1.0.4":"2025-10-09T14:21:26.289Z"},"author":{"name":"Alexandru Gurita"},"license":"MIT","keywords":[],"description":"Simple AWS CloudWatch logger for Node.js using AWS SDK v3","maintainers":[{"name":"alexandru.g","email":"alexandrugurita20@gmail.com"}],"readme":"# 🪵 CloudWatch Custom Logger\r\n\r\n[![npm version](https://img.shields.io/npm/v/@alexandru.g/cloudwatch-custom-logger.svg)](https://www.npmjs.com/package/@alexandru.g/cloudwatch-custom-logger)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)\r\n[![Node.js](https://img.shields.io/badge/node-%3E%3D18-blue.svg)](https://nodejs.org)\r\n\r\nA lightweight, dependency-free Node.js logger for **AWS CloudWatch Logs**, with optional batching, console output, and customizable metadata.\r\n\r\n---\r\n\r\n## 🚀 Installation\r\n\r\n```bash\r\nnpm install \"@alexandru.g/cloudwatch-custom-logger\"\r\n````\r\n\r\n---\r\n\r\n## 🧩 Usage Example\r\n\r\n```js\r\nimport { CloudWatchLogger } from '@alexandru.g/cloudwatch-custom-logger';\r\n\r\nconst logger = new CloudWatchLogger(\r\n  {\r\n    logGroupName: 'MyAppLogs',\r\n    logStreamName: 'ServerStream',\r\n    awsRegion: 'eu-central-1',\r\n    awsAccessKeyId: process.env.AWS_KEY,\r\n    awsSecretKey: process.env.AWS_SECRET,\r\n  },\r\n  { app: 'MyApp', environment: 'production' },\r\n  true // enable console logging\r\n);\r\n\r\nawait logger.init();\r\n\r\nlogger.info('Server started successfully');\r\nlogger.warn('API latency high', { latency: 180 });\r\nlogger.error('Database connection failed', { db: 'users-db' });\r\n\r\n// Batch logs\r\nlogger.debug('User event queued', { userId: 42 }, true);\r\nlogger.debug('Another queued event', { userId: 99 }, true);\r\n\r\n// Send all queued logs in one request\r\nawait logger.flush();\r\n```\r\n\r\n---\r\n\r\n## ⚙️ Configuration\r\n\r\n| Option           | Type      | Required | Description                               |\r\n| ---------------- | --------- | -------- | ----------------------------------------- |\r\n| `logGroupName`   | `string`  | ✅        | The CloudWatch log group name             |\r\n| `logStreamName`  | `string`  | ✅        | The CloudWatch log stream name            |\r\n| `awsRegion`      | `string`  | ✅        | AWS region (e.g. `eu-west-1`)             |\r\n| `awsAccessKeyId` | `string`  | ✅        | AWS access key                            |\r\n| `awsSecretKey`   | `string`  | ✅        | AWS secret key                            |\r\n| `defaults`       | `object`  | ❌        | Default metadata for all logs             |\r\n| `consoleLog`     | `boolean` | ❌        | Whether to also print logs to the console |\r\n\r\n---\r\n\r\n## 🧱 Methods\r\n\r\n### `await logger.init()`\r\n\r\nEnsures the log stream exists. Creates it if necessary.\r\n\r\n---\r\n\r\n### `logger.log(level, message, meta = {}, batch = false)`\r\n\r\nGeneric logging method.\r\nUse one of the convenience wrappers instead (`info`, `warn`, `error`, `debug`).\r\n\r\n**Parameters:**\r\n\r\n* `level` — one of `\"info\" | \"warn\" | \"error\" | \"debug\"`\r\n* `message` — log message string\r\n* `meta` — optional metadata object\r\n* `batch` — if `true`, adds to an internal queue for later flushing\r\n\r\n---\r\n\r\n### `await logger.flush()`\r\n\r\nSends all queued logs to CloudWatch in a single batch request.\r\n\r\n---\r\n\r\n### `logger.changeDefaults(newDefaults)`\r\n\r\nReplaces the default metadata for future logs.\r\n\r\n---\r\n\r\n### Level-specific shortcuts\r\n\r\n| Method                                 | Description    |\r\n| -------------------------------------- | -------------- |\r\n| `logger.info(message, meta?, batch?)`  | Info-level log |\r\n| `logger.warn(message, meta?, batch?)`  | Warning log    |\r\n| `logger.error(message, meta?, batch?)` | Error log      |\r\n| `logger.debug(message, meta?, batch?)` | Debug log      |\r\n\r\n---\r\n\r\n## 🧠 Features\r\n\r\n✅ Simple, clean API\r\n\r\n✅ Supports batching with `flush()`\r\n\r\n✅ Automatically creates log streams\r\n\r\n✅ Includes console fallback logging\r\n\r\n✅ TypeScript-friendly structure\r\n\r\n---\r\n\r\n## 🧪 Example Output\r\n\r\nEach log is JSON-formatted and timestamped automatically:\r\n\r\n```json\r\n{\r\n  \"level\": \"info\",\r\n  \"message\": \"Server started successfully\",\r\n  \"app\": \"MyApp\",\r\n  \"environment\": \"production\",\r\n  \"timestamp\": 1739072381000\r\n}\r\n```\r\n\r\n---\r\n\r\n## 🪪 License\r\n\r\nMIT © [Alexandru Gurita](https://github.com/alexandru-gurita)\r\n\r\n","readmeFilename":"README.md"}