{"_id":"@bookum/logging-client","_rev":"9-03bc8c3bdba529e99bab6ecf878f9507","name":"@bookum/logging-client","dist-tags":{"latest":"1.0.131"},"versions":{"1.0.122":{"name":"@bookum/logging-client","version":"1.0.122","keywords":[],"author":"","license":"ISC","_id":"@bookum/logging-client@1.0.122","maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"dist":{"shasum":"45dee74928a48968d53ea9744f2198209e35390c","tarball":"https://registry.npmjs.org/@bookum/logging-client/-/logging-client-1.0.122.tgz","fileCount":12,"integrity":"sha512-s1Ld7vGlB/jtgJqMq3yLgAFF9WGXB8XRU34kr3UG3yqU0BACE4h/NoFfsfW4TCBbXgwLi46Ui7GGXzxAB5zwBg==","signatures":[{"sig":"MEUCIGPmi7wbMUiYVYluMTWTv28V3xgoR/FDj+uaQfJ2Dq5QAiEAxQj32pOQYDM0nvbBr53uQHfTHJX3FdnRufIdov0EEhQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49464},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"0d53e3d91ecd80bc2cc3adfc19c2b055e89c2fcd","scripts":{"pub":"git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish && git push origin main","build":"npm run clean && tsc","clean":"del ./build/*","prepublishOnly":"npm run build"},"_npmUser":{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"},"_npmVersion":"11.2.0","description":"Internal logging client for Bookum services","directories":{},"_nodeVersion":"23.6.1","dependencies":{"del-cli":"^6.0.0","node-fetch":"^2.7.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.2.2","@types/node":"^20.8.0","@types/express":"^4.17.22","@types/node-fetch":"^2.6.7"},"peerDependencies":{"express":"^4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/logging-client_1.0.122_1748843342988_0.1947497678913117","host":"s3://npm-registry-packages-npm-production"}},"1.0.123":{"name":"@bookum/logging-client","version":"1.0.123","keywords":[],"author":"","license":"ISC","_id":"@bookum/logging-client@1.0.123","maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"dist":{"shasum":"39b9fce9ba05c1a0ba3c137c0cc2057f8723f160","tarball":"https://registry.npmjs.org/@bookum/logging-client/-/logging-client-1.0.123.tgz","fileCount":12,"integrity":"sha512-6y4lMio+ykFcerJ1wl+5zz7ySL+YO2NHQqP/UMBcVJ8uB59iD6pfcm96nmc7kPODK9yrpSlesSHbEMtaysDV0w==","signatures":[{"sig":"MEUCIQD+AOTYMZVxwF+pHkaDddDqeF7nb1/yq3M1vQYFIV3NwgIgNc6wxxu1vePeXhYbNXsd7xAHALoKiWivmDQOYbdi498=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":50138},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"97f595a568e98f108743d8db87249e98ab865b33","scripts":{"pub":"git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish && git push origin main","build":"npm run clean && tsc","clean":"del ./build/*","prepublishOnly":"npm run build"},"_npmUser":{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"},"_npmVersion":"10.9.2","description":"Internal logging client for Bookum services","directories":{},"_nodeVersion":"23.6.1","dependencies":{"del-cli":"^6.0.0","node-fetch":"^2.7.0","@bookum/common":"^1.0.120"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.2.2","@types/node":"^20.8.0","@types/express":"^4.17.22","@types/node-fetch":"^2.6.7"},"peerDependencies":{"express":"^4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/logging-client_1.0.123_1748867221846_0.2722164861715459","host":"s3://npm-registry-packages-npm-production"}},"1.0.124":{"name":"@bookum/logging-client","version":"1.0.124","keywords":[],"author":"","license":"ISC","_id":"@bookum/logging-client@1.0.124","maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"dist":{"shasum":"b7ecebbf4bb99a8fd03c9f64e2e44aa9ef0b72f0","tarball":"https://registry.npmjs.org/@bookum/logging-client/-/logging-client-1.0.124.tgz","fileCount":12,"integrity":"sha512-BH3Uk83yh+DK03SNgZtS/0DZJsMkWibduncKU2H02BN8EJw/ic4yMfKHEV1OjuM2RFddbtMXAN+mpNnDrg6iBA==","signatures":[{"sig":"MEQCIAqYFFg0dwCjdH/VOuTlyapuiITbAJlwjYOp+phcd0hXAiAkwJpDAlvN/JwBdSUhv8knSD6F+YACRKeXdw2DCz4I4w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":50059},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"ffdbdb0a3158429ba80acf08edc2e87bd4855070","scripts":{"pub":"git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish && git push origin main","build":"npm run clean && tsc","clean":"del ./build/*","prepublishOnly":"npm run build"},"_npmUser":{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"},"_npmVersion":"10.9.2","description":"Internal logging client for Bookum services","directories":{},"_nodeVersion":"23.6.1","dependencies":{"del-cli":"^6.0.0","node-fetch":"^2.7.0","@bookum/common":"^1.0.120"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.2.2","@types/node":"^20.8.0","@types/express":"^4.17.22","@types/node-fetch":"^2.6.7"},"peerDependencies":{"express":"^4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/logging-client_1.0.124_1748893721385_0.14985421511130492","host":"s3://npm-registry-packages-npm-production"}},"1.0.125":{"name":"@bookum/logging-client","version":"1.0.125","keywords":[],"author":"","license":"ISC","_id":"@bookum/logging-client@1.0.125","maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"dist":{"shasum":"dbc251f5c098600f5b9bd16d9e27ec493e67e0f5","tarball":"https://registry.npmjs.org/@bookum/logging-client/-/logging-client-1.0.125.tgz","fileCount":12,"integrity":"sha512-sh9cmZ7+U/bj4kTSiylLFASFfgSka1fYe+WlUoH0TXQDax9hKXbMgh3mdZzcNfnVsTE1zmfNlHusVbl29Zt8TQ==","signatures":[{"sig":"MEQCIHxoRLIJZ7bA22r9oGV1X5YAvhyGB4WZDSf2WRzBbKB6AiA2r7yEI7OqzI4VCZaqhLmpzAtklYoaCMJOvpM0eWW2tw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":50081},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"22b1e4a4c7505de7b3b0c3db20b11c9dfc3d5a34","scripts":{"pub":"git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish && git push origin main","build":"npm run clean && tsc","clean":"del ./build/*","prepublishOnly":"npm run build"},"_npmUser":{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"},"_npmVersion":"10.9.2","description":"Internal logging client for Bookum services","directories":{},"_nodeVersion":"23.6.1","dependencies":{"del-cli":"^6.0.0","node-fetch":"^2.7.0","@bookum/common":"^1.0.120"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.2.2","@types/node":"^20.8.0","@types/express":"^4.17.22","@types/node-fetch":"^2.6.7"},"peerDependencies":{"express":"^4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/logging-client_1.0.125_1748895178943_0.21533498442208932","host":"s3://npm-registry-packages-npm-production"}},"1.0.126":{"name":"@bookum/logging-client","version":"1.0.126","keywords":[],"author":"","license":"ISC","_id":"@bookum/logging-client@1.0.126","maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"dist":{"shasum":"dff222259789cf232442b902a3689200cb6ae56c","tarball":"https://registry.npmjs.org/@bookum/logging-client/-/logging-client-1.0.126.tgz","fileCount":12,"integrity":"sha512-oHWGKL3o2B1QDnMwQ1aKVOdOf6soLYEygyuptpscnZmYr3szglupL8aKOGjD+D3WKaYqo2Q8mzCIVIYD55I04w==","signatures":[{"sig":"MEUCIDPbT/bzv+khGwxJHIc/669+41O2eek7ABY1/R6rGu9xAiEA+CrrhqtaQSb/Kob5hnBZmlVF4+imndJM569TpzcwtRM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55319},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"70a57d9ce0cb505db88e70ec5267b0ab0c0586f0","scripts":{"pub":"git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish && git push origin main","build":"npm run clean && tsc","clean":"del ./build/*","prepublishOnly":"npm run build"},"_npmUser":{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"},"_npmVersion":"10.9.2","description":"Internal logging client for Bookum services","directories":{},"_nodeVersion":"23.6.1","dependencies":{"del-cli":"^6.0.0","node-fetch":"^2.7.0","@bookum/common":"^1.0.120"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.2.2","@types/node":"^20.8.0","@types/express":"^4.17.22","@types/node-fetch":"^2.6.7"},"peerDependencies":{"express":"^4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/logging-client_1.0.126_1748928475788_0.8427090804479163","host":"s3://npm-registry-packages-npm-production"}},"1.0.127":{"name":"@bookum/logging-client","version":"1.0.127","keywords":[],"author":"","license":"ISC","_id":"@bookum/logging-client@1.0.127","maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"dist":{"shasum":"e74447f008e536eb6498b051ba7fe0630b7154f5","tarball":"https://registry.npmjs.org/@bookum/logging-client/-/logging-client-1.0.127.tgz","fileCount":12,"integrity":"sha512-cn4i3UCd+kE1jpEz7B/JPiyWkh4+EbKW7wtnsGAoX5ssmYV3FhSfBB0/Om5g1ovj1OA3Ddc1Wko4WMGcULHYMg==","signatures":[{"sig":"MEYCIQD9zfDKbFCpwgIKo70wwYwlLiV8peHyrfr+CbvDhdphNgIhAKsRaIH0L91qFESUH1DnTrOB87rrSoMu9ee8QGJ74FrX","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55452},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"247a001e96fe5b557afae6b82034aed943d85b7e","scripts":{"pub":"git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish && git push origin main","build":"npm run clean && tsc","clean":"del ./build/*","prepublishOnly":"npm run build"},"_npmUser":{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"},"_npmVersion":"10.9.2","description":"Internal logging client for Bookum services","directories":{},"_nodeVersion":"23.6.1","dependencies":{"del-cli":"^6.0.0","node-fetch":"^2.7.0","@bookum/common":"^1.0.120"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.2.2","@types/node":"^20.8.0","@types/express":"^4.17.22","@types/node-fetch":"^2.6.7"},"peerDependencies":{"express":"^4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/logging-client_1.0.127_1748929106999_0.873523747980258","host":"s3://npm-registry-packages-npm-production"}},"1.0.128":{"name":"@bookum/logging-client","version":"1.0.128","keywords":[],"author":"","license":"ISC","_id":"@bookum/logging-client@1.0.128","maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"dist":{"shasum":"594d612f28717576c77a543a31d563204958cb1c","tarball":"https://registry.npmjs.org/@bookum/logging-client/-/logging-client-1.0.128.tgz","fileCount":12,"integrity":"sha512-sD5U00JbqY3QNS+cXctROPgnHEtDzaK4mTaohTEgldZ40yx1eM41jupTkju7kf3HnGvQaxWvNS84pEbCUW6X4Q==","signatures":[{"sig":"MEUCIEpB/WzuabQGupgeGiKDRkWoEYwTLE7wvPCYj7DHUdoyAiEA7vFQJMC4neSahA2Y0EuXG+JY3JtnIHcdjGkM1a4JIvg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55655},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"1f3d50c840edc042e45a637c0e0c32bc17634f68","scripts":{"pub":"git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish && git push origin main","build":"npm run clean && tsc","clean":"del ./build/*","prepublishOnly":"npm run build"},"_npmUser":{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"},"_npmVersion":"10.9.2","description":"Internal logging client for Bookum services","directories":{},"_nodeVersion":"23.6.1","dependencies":{"del-cli":"^6.0.0","node-fetch":"^2.7.0","@bookum/common":"^1.0.120"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.2.2","@types/node":"^20.8.0","@types/express":"^4.17.22","@types/node-fetch":"^2.6.7"},"peerDependencies":{"express":"^4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/logging-client_1.0.128_1748964358065_0.11279762377338365","host":"s3://npm-registry-packages-npm-production"}},"1.0.129":{"name":"@bookum/logging-client","version":"1.0.129","keywords":[],"author":"","license":"ISC","_id":"@bookum/logging-client@1.0.129","maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"dist":{"shasum":"03a77e1f271025294adcd766769f4468b4f5df36","tarball":"https://registry.npmjs.org/@bookum/logging-client/-/logging-client-1.0.129.tgz","fileCount":12,"integrity":"sha512-tRoKcioLNEkrcsVkALJ9Nw4YnNyLN9Up+3gbUfyR2LeblcL8fKB0MGM8k0aoAOC2lD66+fgml6G/56An2sERlg==","signatures":[{"sig":"MEYCIQDy1/eSCkAptdMyNpmr9XxT7ndRLtFlsKZixMdcVcy16gIhAPT2RhQdNf7pI5RG8eXokHwyFksEeB95VmUIOPAn3/it","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56437},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"4af7c0f174e39d79b5bbd8bb45965083ee36d3ab","scripts":{"pub":"git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish && git push origin main","build":"npm run clean && tsc","clean":"del ./build/*","prepublishOnly":"npm run build"},"_npmUser":{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"},"_npmVersion":"10.9.2","description":"Internal logging client for Bookum services","directories":{},"_nodeVersion":"23.6.1","dependencies":{"del-cli":"^6.0.0","node-fetch":"^2.7.0","@bookum/common":"^1.0.120"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.2.2","@types/node":"^20.8.0","@types/express":"^4.17.22","@types/node-fetch":"^2.6.7"},"peerDependencies":{"express":"^4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/logging-client_1.0.129_1749759710643_0.05782547813737349","host":"s3://npm-registry-packages-npm-production"}},"1.0.131":{"name":"@bookum/logging-client","version":"1.0.131","description":"Internal logging client for Bookum services","main":"./build/index.js","types":"./build/index.d.ts","scripts":{"clean":"del ./build/*","build":"npm run clean && tsc","prepublishOnly":"npm run build","pub":"git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish && git push origin main"},"keywords":[],"author":"","license":"ISC","dependencies":{"@bookum/common":"^1.0.120","del-cli":"^6.0.0","node-fetch":"^2.7.0"},"devDependencies":{"@types/express":"^4.17.22","@types/node":"^20.8.0","@types/node-fetch":"^2.6.7","typescript":"^5.2.2"},"peerDependencies":{"express":"^4.18.0"},"_id":"@bookum/logging-client@1.0.131","gitHead":"9c0ada401bb7c0cd5998867f78a9f07b26cec65d","_nodeVersion":"22.17.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-Sg8i/SOAhVmywfaTRA9Da+DP5I7E6SqxA41yBtU6JGtvqjsS2hOPnBpyTUB0QRGum9UbuUgRctF5rhC8a4vK+A==","shasum":"d4370905edb099b699d0a34dbdf2cfaf23eba3f7","tarball":"https://registry.npmjs.org/@bookum/logging-client/-/logging-client-1.0.131.tgz","fileCount":12,"unpackedSize":56953,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIC1JmGyVCrb79vzAryE0k5fPyqyrLavhy+xgK+Qeee27AiEAsqb+Fkq+KHN839602m3Nzh4AXl6OVmmbPe2OLdZlyWU="}]},"_npmUser":{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"},"directories":{},"maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/logging-client_1.0.131_1756993317567_0.2358057500648758"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-02T05:49:02.863Z","modified":"2025-09-04T13:41:57.962Z","1.0.122":"2025-06-02T05:49:03.154Z","1.0.123":"2025-06-02T12:27:02.109Z","1.0.124":"2025-06-02T19:48:41.562Z","1.0.125":"2025-06-02T20:12:59.122Z","1.0.126":"2025-06-03T05:27:55.989Z","1.0.127":"2025-06-03T05:38:27.187Z","1.0.128":"2025-06-03T15:25:58.281Z","1.0.129":"2025-06-12T20:21:50.829Z","1.0.131":"2025-09-04T13:41:57.748Z"},"license":"ISC","keywords":[],"description":"Internal logging client for Bookum services","maintainers":[{"name":"bookumapp","email":"bookumapp@gmail.com"},{"name":"ibmawwal","email":"ibraheemmuhdawwal@gmail.com"}],"readme":"# @bookum/logging-client\n\nInternal logging client for Bookum services with support for structured logging, admin impersonation tracking, and automatic batching.\n\n## Features\n\n- 🚀 **TypeScript Support** - Full type definitions and IntelliSense\n- 📊 **Structured Logging** - Rich metadata and context tracking\n- 👑 **Admin Impersonation** - Track admin actions on behalf of users\n- 🔄 **Automatic Batching** - High-performance log aggregation\n- 🛡️ **Error Handling** - Graceful failure with configurable error handlers\n- 🔌 **Express Middleware** - Automatic API request logging\n- 🏭 **Factory Functions** - Pre-configured loggers for Bookum services\n- 📡 **NATS Integration** - Seamless integration with existing NATS event systems\n\n## Installation\n\n```bash\nnpm install @bookum/logging-client\n```\n\n## Quick Start\n\n### Basic Usage\n\n```typescript\nimport { createServiceLogger, LogLevel, LogType } from '@bookum/logging-client';\n\nconst logger = createServiceLogger({\n  serviceName: 'my-service',\n  environment: 'production',\n});\n\n// Log a user action\nawait logger.log({\n  logType: LogType.USER_EVENT,\n  logLevel: LogLevel.INFO,\n  userId: 'user-123',\n  action: 'profile_updated',\n  metadata: { field: 'email' },\n});\n\n// Log an API request\nawait logger.logApiRequest({\n  userId: 'user-123',\n  method: 'POST',\n  path: '/api/users/profile',\n  responseStatus: 200,\n  duration: 150,\n});\n\n// Log an error\nawait logger.logError({\n  userId: 'user-123',\n  action: 'payment_processing',\n  error: {\n    type: 'ValidationError',\n    message: 'Invalid credit card',\n    code: 'INVALID_CARD',\n  },\n});\n```\n\n## NATS Integration\n\nIf you have an existing NATS event system, you can easily integrate logging:\n\n### 1. Add Log Event to Your Event System\n\n```typescript\n// Add to your subjects enum:\nexport enum Subjects {\n  // ... your existing subjects\n  Log = 'log',\n}\n```\n\n### 2. Use the Log Publisher\n\n```typescript\nimport { LogEventPublisher } from '@bookum/logging-client';\nimport { natsWrapper } from '../nats-wrapper'; // Your existing NATS wrapper\n\nconst logPublisher = new LogEventPublisher(\n  natsWrapper.client,\n  'bookum-api',\n  'production'\n);\n\n// Use as fallback or primary transport\nconst logger = createServiceLogger({\n  serviceName: 'bookum-api',\n  onError: async (error, logData) => {\n    // Publish to NATS on HTTP failure\n    await logPublisher.publishSingleLog(logData);\n  },\n});\n```\n\n### 3. Set Up Consumer in Your Logging Service\n\n```typescript\n// In your dedicated logging service\nconst subscription = nc.subscribe(Subjects.Log);\n\nfor await (const msg of subscription) {\n  const logEvent = JSON.parse(msg.data);\n  await processLogs(logEvent);\n  msg.ack?.();\n}\n```\n\nSee `src/integration-example.md` for detailed integration examples.\n\n### Express Middleware\n\n```typescript\nimport express from 'express';\nimport { createServiceLogger, createAutoLogger } from '@bookum/logging-client';\n\nconst app = express();\nconst logger = createServiceLogger({ serviceName: 'api-service' });\n\n// Auto-log all API requests\napp.use(\n  createAutoLogger({\n    client: logger,\n    includeRequestBody: true,\n    excludePaths: ['/health', '/metrics'],\n  })\n);\n\napp.listen(3000);\n```\n\n### Admin Impersonation Logging\n\n```typescript\n// Log when admin acts on behalf of a user\nawait logger.logAdminImpersonation({\n  adminId: 'admin-456',\n  adminEmail: 'admin@bookum.com',\n  userId: 'user-123',\n  userEmail: 'user@example.com',\n  action: 'update_booking',\n  impersonationSessionId: 'session-789',\n  metadata: { bookingId: 'booking-123' },\n});\n```\n\n## API Reference\n\n### InternalLoggingClient\n\n#### Constructor\n\n```typescript\nnew InternalLoggingClient(config: LoggingClientConfig)\n```\n\n#### Methods\n\n##### `log(logData: Partial<LogEntryData>): Promise<void>`\n\nMain logging method for structured log entries.\n\n##### `logApiRequest(data: {...}): Promise<void>`\n\nConvenience method for logging API requests.\n\n##### `logAdminImpersonation(data: {...}): Promise<void>`\n\nLog admin impersonation events.\n\n##### `logError(data: {...}): Promise<void>`\n\nLog error events with context.\n\n##### `flush(): Promise<void>`\n\nForce flush all pending logs.\n\n##### `shutdown(): Promise<void>`\n\nGraceful shutdown with log flushing.\n\n### Log Types\n\n```typescript\nenum LogType {\n  API_REQUEST = 'api_request',\n  USER_EVENT = 'user_event',\n  ADMIN_IMPERSONATION = 'admin_impersonation',\n  PAYMENT_PROCESSING = 'payment_processing',\n  EMAIL_EVENT = 'email_event',\n  WEBHOOK = 'webhook',\n  SYSTEM_EVENT = 'system_event',\n  ERROR = 'error',\n  AUTHENTICATION = 'authentication',\n  BOOKING_EVENT = 'booking_event',\n}\n```\n\n### Configuration\n\n```typescript\ninterface LoggingClientConfig {\n  baseUrl: string;\n  serviceName: string;\n  environment?: string;\n  enableBatching?: boolean;\n  batchSize?: number;\n  batchTimeout?: number;\n  enableAsync?: boolean;\n  maxQueueSize?: number;\n  onError?: (error: Error, logData: LogEntryData) => void;\n}\n```\n\n## Factory Functions\n\n### Pre-configured Service Loggers\n\n```typescript\nimport { BookumLoggers } from '@bookum/logging-client';\n\nconst apiLogger = BookumLoggers.createApiLogger();\nconst authLogger = BookumLoggers.createAuthLogger();\nconst paymentLogger = BookumLoggers.createPaymentLogger();\n```\n\n### Environment-specific Loggers\n\n```typescript\nimport { createEnvironmentLogger } from '@bookum/logging-client';\n\n// Development logger (immediate, verbose)\nconst devLogger = createEnvironmentLogger.development('my-service');\n\n// Production logger (batched, optimized)\nconst prodLogger = createEnvironmentLogger.production('my-service');\n\n// Test logger (silent errors)\nconst testLogger = createEnvironmentLogger.test('my-service');\n```\n\n## Express Middleware\n\n### Auto Logger\n\n```typescript\napp.use(\n  createAutoLogger({\n    client: logger,\n    includeRequestBody: false, // Include request body in logs\n    includeResponseBody: false, // Include response body in logs\n    excludePaths: ['/health'], // Paths to skip logging\n    extractUserId: (req) => req.user?.id,\n    extractAdminContext: (req) => ({\n      adminId: req.headers['x-admin-id'],\n      adminEmail: req.headers['x-admin-email'],\n      impersonationSessionId: req.headers['x-impersonation-session'],\n    }),\n  })\n);\n```\n\n### Event Logger\n\n```typescript\nimport { createEventLogger } from '@bookum/logging-client';\n\nconst eventLogger = createEventLogger(logger);\n\napp.post('/api/bookings', async (req, res) => {\n  // Your booking logic here\n\n  // Log the booking event\n  await eventLogger.logUserEvent(req, {\n    action: 'booking_created',\n    logType: LogType.BOOKING_EVENT,\n    metadata: { bookingId: booking.id },\n  });\n\n  res.json(booking);\n});\n```\n\n## Environment Variables\n\n```bash\n# Set the logging service URL\nBOOKUM_LOGGING_URL=https://logging.bookum.com/api/logs\n\n# Set environment (affects default configurations)\nNODE_ENV=production\n\n# NATS configuration (if using NATS integration)\nNATS_URL=nats://nats.bookum.internal:4222\n```\n\n## Best Practices\n\n### 1. Use Appropriate Log Levels\n\n```typescript\n// Use INFO for normal user actions\nawait logger.log({\n  logLevel: LogLevel.INFO,\n  logType: LogType.USER_EVENT,\n  // ...\n});\n\n// Use WARN for admin impersonation\nawait logger.log({\n  logLevel: LogLevel.WARN,\n  logType: LogType.ADMIN_IMPERSONATION,\n  // ...\n});\n\n// Use ERROR for failures\nawait logger.log({\n  logLevel: LogLevel.ERROR,\n  logType: LogType.ERROR,\n  // ...\n});\n```\n\n### 2. Include Correlation IDs\n\n```typescript\n// In your middleware\napp.use((req, res, next) => {\n  req.correlationId = req.headers['x-correlation-id'] || generateId();\n  next();\n});\n\n// Use in logs\nawait logger.log({\n  // ...\n  correlationId: req.correlationId,\n});\n```\n\n### 3. Sanitize Sensitive Data\n\n```typescript\n// Don't log sensitive information\nawait logger.log({\n  // ...\n  metadata: {\n    userId: user.id,\n    // DON'T: password: user.password\n    // DON'T: creditCard: payment.cardNumber\n    action: 'password_changed', // OK\n  },\n});\n```\n\n### 4. Use Structured Metadata\n\n```typescript\n// Good: structured metadata\nawait logger.log({\n  // ...\n  metadata: {\n    bookingId: 'booking-123',\n    hotelId: 'hotel-456',\n    checkIn: '2024-01-01',\n    guests: 2,\n  },\n});\n\n// Avoid: unstructured strings\n// metadata: { info: \"booking-123 for hotel-456 with 2 guests\" }\n```\n\n## Error Handling\n\nThe client includes robust error handling:\n\n```typescript\nconst logger = createServiceLogger({\n  serviceName: 'my-service',\n  onError: (error, logData) => {\n    // Custom error handling\n    console.error('Logging failed:', error.message);\n\n    // Could implement fallback logging here\n    // e.g., write to local file, send to alternative service\n  },\n});\n```\n\n## Performance\n\n- **Batching**: Logs are batched by default for better performance\n- **Async**: Non-blocking logging operations\n- **Queue Management**: Configurable queue size with overflow protection\n- **Graceful Shutdown**: Automatic log flushing on process termination\n\n## Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Build the project\nnpm run build\n\n# Clean build artifacts\nnpm run clean\n```\n\n## License\n\nISC\n","readmeFilename":"README.md"}