{"_id":"@apexara/logger","_rev":"7-0f53e3ee472592eae2e8a9cd2196417e","name":"@apexara/logger","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@apexara/logger","version":"1.0.0","license":"ISC","_id":"@apexara/logger@1.0.0","maintainers":[{"name":"simeondspasov","email":"simeon.spasov@apexara.com"},{"name":"ivozhulev","email":"ivo@apexara.com"},{"name":"nikolay-kostadinov","email":"nikolay.kostadinov@apexara.com"}],"dist":{"shasum":"440141c9ae225c969db95b8994108c83e9f9e1bc","tarball":"https://registry.npmjs.org/@apexara/logger/-/logger-1.0.0.tgz","fileCount":4,"integrity":"sha512-3plyyOb+nomOsHDxHw2cqXz+UB2zvV/X5+Gt+a8LwTeM9X8/EdnQ1FP0JD1eIFnfRxJ/gApm3ukPVcYyI2YwTA==","signatures":[{"sig":"MEUCIQD29n4WnZEH90a5P32hF5ApT0UpmHgEa20x8hVEwElUNAIgZRGabQXtdonvQbt0MIfYbJKaTJJ51vf44yVKhlN+m4Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11082},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"a8d7896d87c764a2c05c9b8ca5bea8b8b66445ac","scripts":{"build":"tsc -p tsconfig.json"},"_npmUser":{"name":"ivozhulev","email":"ivo@apexara.com"},"_npmVersion":"10.7.0","description":"A minimal Node.js logger with middleware support","directories":{},"_nodeVersion":"18.20.3","_hasShrinkwrap":false,"devDependencies":{"typescript":"5.9.3","@types/node":"25.2.0"},"_npmOperationalInternal":{"tmp":"tmp/logger_1.0.0_1770049795369_0.11264581934622453","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@apexara/logger","version":"1.0.1","license":"ISC","_id":"@apexara/logger@1.0.1","maintainers":[{"name":"simeondspasov","email":"simeon.spasov@apexara.com"},{"name":"ivozhulev","email":"ivo@apexara.com"},{"name":"nikolay-kostadinov","email":"nikolay.kostadinov@apexara.com"}],"dist":{"shasum":"d6f8f306f421c8496b50820f81a91137e13060ad","tarball":"https://registry.npmjs.org/@apexara/logger/-/logger-1.0.1.tgz","fileCount":4,"integrity":"sha512-m02a2nb7JwpE3xLXGbZxOtTMbiDlpO4Era1kiO2AiqdemdkQQQveoGjHdPtlZuaWJ3kmFGy3UVLFXdpDAVSjsA==","signatures":[{"sig":"MEUCIQDe61qoPYoNbl3hiINB6fL8ELWCjwWzbnJa7cQQ2mLonAIgQnAbAnP+/8+9yNMZm330W8Pm0mhC1mBhivjHklVmxT0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11931},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"d659011fbdf38bac1731b8f164559da29dd8825a","scripts":{"build":"tsc -p tsconfig.json"},"_npmUser":{"name":"ivozhulev","email":"ivo@apexara.com"},"_npmVersion":"10.7.0","description":"A minimal Node.js logger with middleware support","directories":{},"_nodeVersion":"18.20.3","_hasShrinkwrap":false,"devDependencies":{"typescript":"5.9.3","@types/node":"25.2.0"},"_npmOperationalInternal":{"tmp":"tmp/logger_1.0.1_1772115600151_0.30693536375904573","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@apexara/logger","version":"1.0.2","license":"ISC","_id":"@apexara/logger@1.0.2","maintainers":[{"name":"simeondspasov","email":"simeon.spasov@apexara.com"},{"name":"ivozhulev","email":"ivo@apexara.com"},{"name":"nikolay-kostadinov","email":"nikolay.kostadinov@apexara.com"}],"dist":{"shasum":"76285d2481834b67cd7d233bd637a5fdecd19fa9","tarball":"https://registry.npmjs.org/@apexara/logger/-/logger-1.0.2.tgz","fileCount":4,"integrity":"sha512-gH+s5De27pdg3fhIJ8oFXx8FBAWWn4mETtg8Lqg4UNH0EPL7zez9hnzQ+CH/wxwxi2/V/a92n9PYC1ULZXhn8w==","signatures":[{"sig":"MEUCIQC1YADyRdGE/S9WIe8kqsXLHg9LpuaZxrYVCLL11KilSgIgDXZUZO0//g4AWiuCgaYhvF+0oVjZOvsgAhpwOK/jul0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11853},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"918eafb4c48a55c75a4cf0b02439dc44738396d0","scripts":{"build":"tsc -p tsconfig.json"},"_npmUser":{"name":"ivozhulev","email":"ivo@apexara.com"},"_npmVersion":"10.7.0","description":"A minimal Node.js logger with middleware support","directories":{},"_nodeVersion":"18.20.3","_hasShrinkwrap":false,"devDependencies":{"typescript":"5.9.3","@types/node":"25.2.0"},"_npmOperationalInternal":{"tmp":"tmp/logger_1.0.2_1772115777965_0.04564322419284417","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@apexara/logger","version":"1.1.0","license":"ISC","_id":"@apexara/logger@1.1.0","maintainers":[{"name":"simeondspasov","email":"simeon.spasov@apexara.com"},{"name":"ivozhulev","email":"ivo@apexara.com"},{"name":"nikolay-kostadinov","email":"nikolay.kostadinov@apexara.com"},{"name":"martinpetrovapex","email":"martin.petrov@apexara.com"}],"dist":{"shasum":"45f3d1219183eb4bc372cd1d0a4d5328bd306bc9","tarball":"https://registry.npmjs.org/@apexara/logger/-/logger-1.1.0.tgz","fileCount":4,"integrity":"sha512-yM9Y0q9UYspOzTVzjSC3sS6VbcJpWxMJyXxzodiPdg4gIrCH3QpTunu0kvwqmUm2mhIOnpWy192nzGSbjFiBVQ==","signatures":[{"sig":"MEQCIEDpbUKc6pbi/Hrle79Q98dqi4rLIVMoiyDOkQZ6pHIzAiAV3DTacDq13d4YjcBDLVu/zlPGBvMRjYLb6EkWNU5/gQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12293},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"5535daceceb47a88fce926daac11532de622ae41","scripts":{"build":"tsc -p tsconfig.json"},"_npmUser":{"name":"ivozhulev","email":"ivo@apexara.com"},"_npmVersion":"10.7.0","description":"A minimal Node.js logger with middleware support","directories":{},"_nodeVersion":"18.20.3","_hasShrinkwrap":false,"devDependencies":{"typescript":"6.0.2","@types/node":"25.5.0"},"_npmOperationalInternal":{"tmp":"tmp/logger_1.1.0_1775575091818_0.3484914254402727","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@apexara/logger","version":"1.1.1","description":"A minimal Node.js logger with middleware support","license":"ISC","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsc -p tsconfig.json"},"devDependencies":{"@types/node":"25.5.0","typescript":"6.0.2"},"_id":"@apexara/logger@1.1.1","gitHead":"1c8ec396f841b361bc927fdfed2d3f69d86a3600","_nodeVersion":"18.20.3","_npmVersion":"10.7.0","dist":{"integrity":"sha512-7AapzY89gYsujY4EfeNYXWRnS++sR90ZCKnSsPThu+hHyZvJePU1WmlD/cnxlE+LLEggjQeCccSGk7hqYmPMpw==","shasum":"250e814875f44b965008f8bb370ac15f199c3bc3","tarball":"https://registry.npmjs.org/@apexara/logger/-/logger-1.1.1.tgz","fileCount":4,"unpackedSize":12329,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDKCnASrCOFBJq/r6IyD6vpIa50RfCjBRA5zMudEeUY1AiEA8NXdbKXbggEgfXxACX/pvXS33gorYclGr6/qY0UwGPk="}]},"_npmUser":{"name":"ivozhulev","email":"ivo@apexara.com"},"directories":{},"maintainers":[{"name":"simeondspasov","email":"simeon.spasov@apexara.com"},{"name":"ivozhulev","email":"ivo@apexara.com"},{"name":"nikolay-kostadinov","email":"nikolay.kostadinov@apexara.com"},{"name":"martinpetrovapex","email":"martin.petrov@apexara.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/logger_1.1.1_1775576280505_0.8788852444980124"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-02T16:29:55.368Z","modified":"2026-04-07T15:38:00.834Z","1.0.0":"2026-02-02T16:29:55.510Z","1.0.1":"2026-02-26T14:20:00.295Z","1.0.2":"2026-02-26T14:22:58.117Z","1.1.0":"2026-04-07T15:18:11.976Z","1.1.1":"2026-04-07T15:38:00.652Z"},"license":"ISC","description":"A minimal Node.js logger with middleware support","maintainers":[{"name":"simeondspasov","email":"simeon.spasov@apexara.com"},{"name":"ivozhulev","email":"ivo@apexara.com"},{"name":"nikolay-kostadinov","email":"nikolay.kostadinov@apexara.com"},{"name":"martinpetrovapex","email":"martin.petrov@apexara.com"}],"readme":"# @apexara/logger\n\nA minimal Node.js logger with middleware support. Provides `info`, `error`, and `debug` logging, ANSI color output, and duplicate error suppression.\n\n## Install\n\n```sh\nnpm install @apexara/logger\n```\n\n## Quick start\n\n```ts\nimport logger from '@apexara/logger';\n\nlogger.info('Server started');\nlogger.error('Connection failed', 'db');\nlogger.debug({ port: 8080 });\n```\n\nThe module also assigns a global instance:\n\n```ts\nimport '@apexara/logger';\n\nlogger.info('Using the global logger');\n```\n\n### TypeScript 6+ global setup\n\nWith TypeScript 6 and `module: \"nodenext\"`, a side-effect import only makes the global available in the importing file. To get project-wide type support for `logger`, add the package to `types` in your `tsconfig.json`:\n\n```json\n{\n  \"compilerOptions\": {\n    \"types\": [\"@apexara/logger\"]\n  }\n}\n```\n\nThis tells TypeScript to include the global `logger` declaration across all files without needing an import in each one.\n\n## API\n\n### logger.info(message, options?)\n\n```ts\nlogger.info('Ready', { color: '36', tags: ['startup'] });\n```\n\n### logger.error(message, source, options?)\n\n```ts\nlogger.error('Timeout', 'payments', { color: '33', meta: { timeoutMs: 5000 } });\n```\n\n### logger.debug(object, inspectOptions?, options?)\n\n```ts\nlogger.debug({ config: { retries: 3 } }, { depth: 4 });\n```\n\n### Call options\n\n- `color`: ANSI color code as a string, e.g. `'31'` (red), `'32'` (green), `'33'` (yellow), `'37'` (white).\n- `tags`: string array, intended for middleware.\n- `meta`: free-form key/value data, intended for middleware.\n\n### Timestamps and formatting\n\n- Timestamps are formatted in 24-hour time with the `Europe/Sofia` timezone.\n- Output is ANSI-colored; disable colors by running your process without a color-capable terminal.\n\n## Middleware\n\nMiddlewares can enrich or alter log behavior. They receive a mutable `LoggerOptions` object and a `next` function.\n\n```ts\nimport logger, { LoggerMiddleware } from '@apexara/logger';\n\nconst addTag: LoggerMiddleware = async (options, next) => {\n  options.tags = [...(options.tags ?? []), 'api'];\n  await next();\n};\n\nlogger.addMiddleware(addTag);\n```\n\nLevel-specific middleware:\n\n```ts\nlogger.addInfoMidldeware(async (options, next) => {\n  options.color = options.color ?? '32';\n  await next();\n});\n\nlogger.addDebugMidldeware(async (options, next) => {\n  options.meta = { ...(options.meta ?? {}), debug: true };\n  await next();\n});\n\nlogger.addErrorMidldeware(async (options, next) => {\n  options.color = options.color ?? '31';\n  await next();\n});\n```\n\n### Example: Send emails on error\n\nYou can use an error middleware to send email notifications when errors occur:\n\n```ts\nimport logger from '@apexara/logger';\n\nlogger.addErrorMidldeware(async (options, next) => {\n  await next();\n\n  if (config.env === 'dev') {\n    return;\n  }\n\n  const emailData = {\n    toEmail: config.devEmail,\n    subject: `${config.appName} ${config.env.toUpperCase()} Error`,\n    template: 'error',\n    payload: {\n      where: options.source,\n      message: options.message,\n    },\n  };\n\n  emailUtil.sendEmail(emailData, EmailType.Info, '')\n    .catch(err => console.dir(err, { depth: 10 }));\n});\n```\n\nCalling `await next()` first ensures the error is logged before the email is sent. You can also skip `next()` entirely to suppress the log output.\n\nNote: `tags` and `meta` are not rendered by the default logger output; they are intended for middleware or external handlers.\n\n## Duplicate error suppression\n\nRepeated error logs with the same `source` and `message` are suppressed for 60 seconds by default. A summary is printed after the interval.\n\n```ts\nlogger.suppressionIntervalMs = 10_000;\n```\n\n## Types\n\nThe package exports the following TypeScript types:\n\n- `LogType`\n- `LoggerOptions`\n- `LogCallOptions`\n- `LoggerMiddleware`\n\n## License\n\nISC\n","readmeFilename":"README.md"}