{"_id":"@aitc/logger","name":"@aitc/logger","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@aitc/logger","version":"1.0.0","description":"AITC logging utility with requestId and service name support. Built on winston with customizable transports.","main":"index.js","keywords":["logger","winston","logging","request-id","service-name","aitc"],"author":{"name":"AITC"},"license":"ISC","engines":{"node":">=22.21.0"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":""},"dependencies":{"winston":"^3.18.3"},"devDependencies":{"eslint":"^9.14.0","jest":"^29.7.0","prettier":"^3.3.3"},"scripts":{"test":"jest","lint":"eslint .","lint:fix":"eslint . --fix","format":"prettier --write .","format:check":"prettier --check ."},"gitHead":"d47917abbb8b8893922a4b3e3b8907fb5eaeedcf","_id":"@aitc/logger@1.0.0","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-vWm6W1O1MOLkGROb5jVXqcBwaZZbFITmtylL9X6SA6MMNWMCXtzw2M64fTWHV8Vd+LmFg79A9alHVsYwZku0+w==","shasum":"b83156ac6bceffcbf0f35b908d4456dce0dc5df3","tarball":"https://registry.npmjs.org/@aitc/logger/-/logger-1.0.0.tgz","fileCount":4,"unpackedSize":8919,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDLdccGO3n0ajLc8WSZe58l+jC6Tm66Q728L/GfixuxNwIhAOHmSkE5qHtbKu8H/JiHb1sEDja5lI+WpMkXgYLCaGaX"}]},"_npmUser":{"name":"kashifurrehman79","email":"kashifkhankk799872@gmail.com"},"directories":{},"maintainers":[{"name":"kashifurrehman79","email":"kashifkhankk799872@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/logger_1.0.0_1767949568580_0.9988112934723434"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-09T09:06:08.471Z","1.0.0":"2026-01-09T09:06:08.757Z","modified":"2026-01-09T09:06:09.112Z"},"maintainers":[{"name":"kashifurrehman79","email":"kashifkhankk799872@gmail.com"}],"description":"AITC logging utility with requestId and service name support. Built on winston with customizable transports.","keywords":["logger","winston","logging","request-id","service-name","aitc"],"repository":{"type":"git","url":""},"author":{"name":"AITC"},"license":"ISC","readme":"# @aitc/logger\n\nAITC logging utility with requestId and service name support. Built on winston with customizable transports.\n\n## Installation\n\n```bash\nnpm install @aitc/logger\n```\n\n## Quick Start\n\n```javascript\nconst { createLogger } = require(\"@aitc/logger\");\n\nconst logger = createLogger({\n  level: process.env.LOG_LEVEL || \"info\",\n  service: \"property-service\",\n  transports: [\"console\", \"file\"],\n  logDir: __dirname,\n});\n\n// Use the logger\nlogger.info(\"Application started\", { requestId: \"abc123\" });\nlogger.error(\"Something went wrong\", { error: error.message, requestId: \"abc123\" });\n```\n\n## Configuration Options\n\n### `createLogger(options)`\n\nCreates a logger instance with the following options:\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `level` | string | `process.env.LOG_LEVEL \\|\\| \"info\"` | Log level (info, error, warn, debug) |\n| `service` | string | `null` | Service name to include in logs |\n| `transports` | Array<string> | `[\"console\"]` | Transport types: `\"console\"`, `\"file\"` |\n| `logDir` | string | `process.cwd()` | Directory for log files (only if file transport enabled) |\n| `errorLogFile` | string | `\"error.log\"` | Error log filename |\n| `combinedLogFile` | string | `\"combined.log\"` | Combined log filename |\n\n## Usage Examples\n\n### Basic Usage (Console Only)\n\n```javascript\nconst { createLogger } = require(\"@aitc/logger\");\n\nconst logger = createLogger({\n  level: \"info\",\n  service: \"my-service\",\n});\n\nlogger.info(\"User logged in\", { userId: 123, requestId: \"req-456\" });\nlogger.error(\"Database connection failed\", { error: err.message, requestId: \"req-456\" });\n```\n\n### With File Logging\n\n```javascript\nconst { createLogger } = require(\"@aitc/logger\");\nconst path = require(\"path\");\n\nconst logger = createLogger({\n  level: process.env.LOG_LEVEL || \"info\",\n  service: \"property-service\",\n  transports: [\"console\", \"file\"],\n  logDir: path.join(__dirname, \"logs\"),\n  errorLogFile: \"error.log\",\n  combinedLogFile: \"combined.log\",\n});\n```\n\n### Using Environment Variables\n\n```javascript\nconst { createLogger } = require(\"@aitc/logger\");\n\n// LOG_LEVEL is automatically read from process.env\nconst logger = createLogger({\n  service: \"auth-service\",\n  transports: [\"console\"],\n});\n```\n\n### Migration from Old Logger\n\nIf you're migrating from the old logger that used a config file:\n\n**Before:**\n```javascript\nconst logger = require(\"../utils/logger\");\nconst config = require(\"../config/config\");\n```\n\n**After:**\n```javascript\nconst { createLogger } = require(\"@aitc/logger\");\nconst config = require(\"../config/config\");\n\nconst logger = createLogger({\n  level: config.log_level || process.env.LOG_LEVEL || \"info\",\n  service: \"property-service\",\n  transports: [\"console\", \"file\"],\n  logDir: __dirname,\n});\n```\n\n## API\n\n### `logger.info(message, meta)`\nLogs an info message.\n\n**Parameters:**\n- `message` (string): Log message\n- `meta` (object): Metadata object. Special fields:\n  - `requestId`: Request ID to include in log\n  - `service`: Service name (overrides default service)\n  - Any other fields will be JSON stringified\n\n### `logger.error(message, meta)`\nLogs an error message.\n\n### `logger.warn(message, meta)`\nLogs a warning message.\n\n### `logger.debug(message, meta)`\nLogs a debug message.\n\n### `logger.raw`\nAccess to the underlying winston logger instance for advanced usage.\n\n## Log Format\n\nLogs are formatted as:\n```\nYYYY-MM-DD HH:mm:ss [LEVEL] [service-name] [request-id: requestId] message {metadata}\n```\n\n**Example:**\n```\n2026-01-09 12:30:45 [INFO] [property-service] [request-id: abc123] User logged in {\"userId\":123}\n```\n\n## Environment Variables\n\n- `LOG_LEVEL`: Sets the default log level (info, error, warn, debug)\n\n## License\n\nISC\n\n## Support\n\nFor issues and questions, please contact the AITC development team.\n\n","readmeFilename":"README.md","_rev":"1-3a1516e515c04a7cc94ce77ebacc2c46"}