{"_id":"@c5h-soft/discord-logger","_rev":"2-dad5a911f15cbadb692744c1fd9debf2","name":"@c5h-soft/discord-logger","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@c5h-soft/discord-logger","version":"1.0.0","keywords":["discord","logger","webhook","pino","logging","notifications"],"author":{"name":"c5h.dev"},"license":"MIT","_id":"@c5h-soft/discord-logger@1.0.0","maintainers":[{"name":"c5h","email":"npm@c5h.dev"}],"homepage":"https://github.com/c5h-soft/discord-logger#readme","bugs":{"url":"https://github.com/c5h-soft/discord-logger/issues"},"dist":{"shasum":"eb0ddf69b23b02e9afe89e945881b3299d44dd8a","tarball":"https://registry.npmjs.org/@c5h-soft/discord-logger/-/discord-logger-1.0.0.tgz","fileCount":7,"integrity":"sha512-jqM9EPtgYiu9ZPGOTdgoyvosbIv1Qfnpt2j8B/ETAySb0OyyUC8O0tdQe/Ouqk+d9Dvka1MttdRMqMI3jk3TRg==","signatures":[{"sig":"MEUCIBgJRyMkP+jNK8NmgHVeHnnyqrdJ48bFwLf5MA5U90H/AiEAnFJAKmMGVlz1cQ7xtgK9rCRTdRWSJijXn/s+VwjxhXY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45999},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"9f232ca760042f11c0cf31cdef702dad51f90c59","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","test":"vitest run","build":"tsup src/index.ts --format cjs,esm --dts --clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"c5h","email":"npm@c5h.dev"},"repository":{"url":"git+https://github.com/c5h-soft/discord-logger.git","type":"git"},"_npmVersion":"10.9.2","description":"Lightweight Discord webhook logger with pino integration, colored output, and timezone support","directories":{},"_nodeVersion":"22.14.0","dependencies":{"pino":"^9.5.0","pino-pretty":"^13.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.10.1"},"_npmOperationalInternal":{"tmp":"tmp/discord-logger_1.0.0_1765535299900_0.8452936044097921","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@c5h-soft/discord-logger","version":"1.0.1","description":"Lightweight Discord webhook logger with pino integration, colored output, and timezone support","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","dev":"tsup src/index.ts --format cjs,esm --dts --watch","prepublishOnly":"npm run build","test":"vitest run","test:watch":"vitest"},"keywords":["discord","logger","webhook","pino","logging","notifications"],"author":{"name":"c5h.dev"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/c5h-soft/discord-logger.git"},"homepage":"https://github.com/c5h-soft/discord-logger#readme","bugs":{"url":"https://github.com/c5h-soft/discord-logger/issues"},"dependencies":{"pino":"^9.5.0"},"optionalDependencies":{"pino-pretty":"^13.0.0"},"devDependencies":{"@types/node":"^22.19.2","tsup":"^8.3.5","typescript":"^5.7.2","vitest":"^2.1.8"},"engines":{"node":">=18"},"_id":"@c5h-soft/discord-logger@1.0.1","gitHead":"ce0686bb3e3a7e9945d2f0b7f279534aca3d40bd","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-qujGg+GBlklrGzYNzmcw1aqvIoDd5+ED7A8ce96oEYMGtHRC0h8EDsuhd5bj77EKB2/NcELv4XJYLtqiD7K3Tw==","shasum":"aceb2bc615996d466fb7d7761f52ebd0d264520a","tarball":"https://registry.npmjs.org/@c5h-soft/discord-logger/-/discord-logger-1.0.1.tgz","fileCount":7,"unpackedSize":272633,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEQuRFfbt5PpiGhx51RxevbaiVTknzCD0iIUv9sktBlFAiEAtCe8oIUQPgkUyNcT3SIdP125CcUwqMml0L9Qt+dAg2U="}]},"_npmUser":{"name":"c5h","email":"npm@c5h.dev"},"directories":{},"maintainers":[{"name":"c5h","email":"npm@c5h.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/discord-logger_1.0.1_1765547021405_0.2770011133822754"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-12T10:28:19.798Z","modified":"2025-12-12T13:43:41.775Z","1.0.0":"2025-12-12T10:28:20.077Z","1.0.1":"2025-12-12T13:43:41.566Z"},"bugs":{"url":"https://github.com/c5h-soft/discord-logger/issues"},"author":{"name":"c5h.dev"},"license":"MIT","homepage":"https://github.com/c5h-soft/discord-logger#readme","keywords":["discord","logger","webhook","pino","logging","notifications"],"repository":{"type":"git","url":"git+https://github.com/c5h-soft/discord-logger.git"},"description":"Lightweight Discord webhook logger with pino integration, colored output, and timezone support","maintainers":[{"name":"c5h","email":"npm@c5h.dev"}],"readme":"# @c5h-soft/discord-logger\n\nLightweight Discord webhook logger with [pino](https://github.com/pinojs/pino) integration, colored console output, and timezone support.\n\nPerfect for monitoring your applications in real-time through Discord webhooks.\n\n## Features\n\n- 🚀 **Simple API** - Initialize once, use everywhere\n- 🎨 **Colored console output** - Beautiful logs in development\n- 🌍 **Timezone support** - Configure timestamps for your region\n- 📊 **Pino integration** - Professional logging with structured data\n- 🔔 **Discord webhooks** - Real-time notifications to your Discord channel\n- 📦 **TypeScript** - Full type support out of the box\n- 🪶 **Lightweight** - Minimal dependencies\n\n## Installation\n\n```bash\nnpm install @c5h-soft/discord-logger\n# or\nyarn add @c5h-soft/discord-logger\n# or\npnpm add @c5h-soft/discord-logger\n```\n\n## Quick Start\n\n### 1. Initialize the logger (once at app startup)\n\n```typescript\n// For Next.js: src/instrumentation.ts\nimport { initDiscordLogger } from \"@c5h-soft/discord-logger\";\n\nexport async function register() {\n  if (process.env.NEXT_RUNTIME === \"nodejs\") {\n    initDiscordLogger({\n      webhookUrl: process.env.DISCORD_WEBHOOK_URL,\n      timezone: \"America/Argentina/Buenos_Aires\",\n      locale: \"es-AR\",\n      appName: \"my-app\",\n      debug: process.env.NODE_ENV === \"development\",\n    });\n  }\n}\n```\n\n```typescript\n// For Express/Node.js: src/index.ts\nimport { initDiscordLogger } from \"@c5h-soft/discord-logger\";\n\ninitDiscordLogger({\n  webhookUrl: process.env.DISCORD_WEBHOOK_URL,\n  appName: \"api-server\",\n});\n```\n\n### 2. Use the logger anywhere\n\n```typescript\nimport { log } from \"@c5h-soft/discord-logger\";\n\n// Simple messages\nlog.info(\"Server started on port 3000\");\nlog.warn(\"Deprecated function called\");\nlog.error(\"Database connection failed\", new Error(\"Connection refused\"));\nlog.debug(\"Request payload\", { userId: 123, action: \"login\" });\n\n// Structured event logging\nlog.info({\n  event: \"user.registered\",\n  timestamp: new Date(),\n  userId: \"123\",\n  email: \"user@example.com\",\n  provider: \"google\",\n});\n```\n\n## Configuration Options\n\n| Option           | Type                | Default       | Description                                                              |\n| ---------------- | ------------------- | ------------- | ------------------------------------------------------------------------ |\n| `webhookUrl`     | `string`            | `undefined`   | Discord webhook URL. Required for Discord logging.                       |\n| `timezone`       | `string`            | `'UTC'`       | Timezone for timestamps (e.g., `'America/New_York'`, `'Europe/London'`). |\n| `locale`         | `string`            | `'en-US'`     | Locale for date formatting (e.g., `'es-AR'`, `'de-DE'`).                 |\n| `appName`        | `string`            | `'app'`       | Application name shown in logs.                                          |\n| `debug`          | `boolean`           | `false`       | Enable debug level logging.                                              |\n| `colors`         | `boolean`           | `true` in dev | Enable colored console output.                                           |\n| `disableDiscord` | `boolean`           | `false`       | Disable Discord logging (useful for testing).                            |\n| `disableConsole` | `boolean`           | `false`       | Disable console logging entirely.                                        |\n| `pinoOptions`    | `PinoLoggerOptions` | `{}`          | Custom pino configuration options.                                       |\n\n## API Reference\n\n### `initDiscordLogger(config)`\n\nInitialize the logger with your configuration. Call this once at application startup.\n\n```typescript\nimport { initDiscordLogger } from \"@c5h-soft/discord-logger\";\n\ninitDiscordLogger({\n  webhookUrl: process.env.DISCORD_WEBHOOK_URL,\n  timezone: \"America/Argentina/Buenos_Aires\",\n  locale: \"es-AR\",\n  appName: \"my-app\",\n  debug: true,\n  colors: true,\n});\n```\n\n### `log.info(message, data?)`\n\nLog an informational message.\n\n```typescript\nlog.info(\"User logged in\");\nlog.info(\"Processing request\", { userId: 123, path: \"/api/users\" });\nlog.info({ event: \"payment.completed\", amount: 100, userId: \"456\" });\n```\n\n### `log.error(message, error?)`\n\nLog an error message with optional error object.\n\n```typescript\nlog.error(\"Something went wrong\");\nlog.error(\"Database query failed\", new Error(\"Connection timeout\"));\nlog.error(\"API call failed\", { status: 500, body: \"Internal error\" });\n```\n\n### `log.warn(message, data?)`\n\nLog a warning message.\n\n```typescript\nlog.warn(\"Rate limit approaching\");\nlog.warn(\"Deprecated API called\", { endpoint: \"/v1/users\", by: \"client-123\" });\n```\n\n### `log.debug(message, data?)`\n\nLog a debug message (only when `debug: true` is configured).\n\n```typescript\nlog.debug(\"Cache hit\", { key: \"user:123\" });\nlog.debug({ query: \"SELECT * FROM users\", duration: 45 });\n```\n\n### `log.child(bindings)`\n\nCreate a child logger with additional context.\n\n```typescript\nconst requestLog = log.child({ requestId: \"abc-123\", userId: 456 });\nrequestLog.info(\"Processing request\");\nrequestLog.error(\"Request failed\", new Error(\"Not found\"));\n```\n\n### `log.getPino()`\n\nGet the underlying pino logger instance for advanced usage.\n\n```typescript\nconst pinoLogger = log.getPino();\npinoLogger.info({ custom: \"data\" }, \"Using pino directly\");\n```\n\n## Event Formatting\n\nThe logger automatically formats event objects with special handling for common event types:\n\n```typescript\nlog.info({\n  event: \"user.registered\",\n  timestamp: new Date(),\n  userId: \"123\",\n  email: \"john@example.com\",\n  name: \"John Doe\",\n  provider: \"google\",\n});\n```\n\nDiscord output:\n\n```\nℹ️ [my-app] **USER.REGISTERED** - 12/12/2025, 10:30:00\nUser: 123 • Email: john@example.com • Name: John Doe • Provider: google\n```\n\nSupported event patterns:\n\n- `user.*` - User events (login, register, etc.)\n- `payment.*` - Payment events (amount, credits)\n- `job.*` - Job events (title, company)\n- `application.*` - Application events\n- `api_key.*` - API key events\n- `webhook.*` - Webhook events\n\n## Development vs Production\n\nIn development (`NODE_ENV=development`):\n\n- Colored console output using pino-pretty\n- Human-readable timestamps\n- Debug messages shown (if enabled)\n\nIn production:\n\n- JSON structured logging via pino\n- Optimized for log aggregation services\n- Discord notifications for monitoring\n\n## Environment Variables\n\n```bash\n# Required for Discord logging\nDISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...\n\n# Optional\nNODE_ENV=development  # Enables colored output\n```\n\n## Common Timezone Values\n\n| Timezone                         | Region                     |\n| -------------------------------- | -------------------------- |\n| `UTC`                            | Coordinated Universal Time |\n| `America/New_York`               | Eastern US                 |\n| `America/Chicago`                | Central US                 |\n| `America/Denver`                 | Mountain US                |\n| `America/Los_Angeles`            | Pacific US                 |\n| `America/Argentina/Buenos_Aires` | Argentina                  |\n| `America/Sao_Paulo`              | Brazil                     |\n| `America/Mexico_City`            | Mexico                     |\n| `Europe/London`                  | UK                         |\n| `Europe/Paris`                   | Central Europe             |\n| `Europe/Berlin`                  | Germany                    |\n| `Europe/Madrid`                  | Spain                      |\n| `Asia/Tokyo`                     | Japan                      |\n| `Asia/Shanghai`                  | China                      |\n| `Asia/Singapore`                 | Singapore                  |\n| `Asia/Dubai`                     | UAE                        |\n| `Asia/Kolkata`                   | India                      |\n| `Australia/Sydney`               | Australia (East)           |\n\n📋 **Full list:** [IANA Time Zone Database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)\n\n## Common Locale Values\n\n| Locale  | Language / Region        |\n| ------- | ------------------------ |\n| `en-US` | English (United States)  |\n| `en-GB` | English (United Kingdom) |\n| `es-ES` | Spanish (Spain)          |\n| `es-AR` | Spanish (Argentina)      |\n| `es-MX` | Spanish (Mexico)         |\n| `pt-BR` | Portuguese (Brazil)      |\n| `pt-PT` | Portuguese (Portugal)    |\n| `fr-FR` | French (France)          |\n| `de-DE` | German (Germany)         |\n| `it-IT` | Italian (Italy)          |\n| `ja-JP` | Japanese (Japan)         |\n| `zh-CN` | Chinese (Simplified)     |\n| `zh-TW` | Chinese (Traditional)    |\n| `ko-KR` | Korean (South Korea)     |\n| `ru-RU` | Russian (Russia)         |\n| `ar-SA` | Arabic (Saudi Arabia)    |\n| `hi-IN` | Hindi (India)            |\n\n📋 **Full list:** [BCP 47 Language Tags](https://www.techonthenet.com/js/language_tags.php) | [MDN Intl.Locale](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale)\n\n## Examples\n\n### Next.js App Router\n\n```typescript\n// src/instrumentation.ts\nimport { initDiscordLogger, log } from \"@c5h-soft/discord-logger\";\n\nexport async function register() {\n  if (process.env.NEXT_RUNTIME === \"nodejs\") {\n    initDiscordLogger({\n      webhookUrl: process.env.DISCORD_WEBHOOK_URL,\n      appName: \"nextjs-app\",\n      timezone: \"UTC\",\n    });\n    log.info(\"Application started\");\n  }\n}\n```\n\n### Express Server\n\n```typescript\nimport express from \"express\";\nimport { initDiscordLogger, log } from \"@c5h-soft/discord-logger\";\n\ninitDiscordLogger({\n  webhookUrl: process.env.DISCORD_WEBHOOK_URL,\n  appName: \"api-server\",\n});\n\nconst app = express();\n\napp.use((req, res, next) => {\n  log.debug(\"Request received\", { method: req.method, path: req.path });\n  next();\n});\n\napp.listen(3000, () => {\n  log.info(\"Server started on port 3000\");\n});\n```\n\n### Error Handling\n\n```typescript\nimport { log } from \"@c5h-soft/discord-logger\";\n\nasync function processPayment(userId: string, amount: number) {\n  try {\n    const result = await paymentService.charge(userId, amount);\n    log.info({\n      event: \"payment.completed\",\n      timestamp: new Date(),\n      userId,\n      amount,\n      transactionId: result.id,\n    });\n    return result;\n  } catch (error) {\n    log.error(\"Payment processing failed\", error);\n    throw error;\n  }\n}\n```\n\n## License\n\nMIT © [c5h.dev](https://c5h.dev)\n\n---\n\nMade with ❤️ by [c5h.dev](https://c5h.dev) - Custom software development\n","readmeFilename":"README.md"}