{"id":28089251,"url":"https://github.com/jokr-services/logr-node","last_synced_at":"2025-10-16T19:47:31.888Z","repository":{"id":199249368,"uuid":"654399512","full_name":"JOKR-Services/logr-node","owner":"JOKR-Services","description":"This TypeScript log standardization library offers an easy and flexible way to standardize your application's logs. ","archived":false,"fork":false,"pushed_at":"2024-09-10T13:34:03.000Z","size":996,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-29T21:48:36.248Z","etag":null,"topics":["decorator","exception-handler","log","logger","node"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JOKR-Services.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-16T03:39:03.000Z","updated_at":"2024-09-10T13:37:23.000Z","dependencies_parsed_at":"2023-11-14T21:29:35.030Z","dependency_job_id":"74c14e0c-58c2-41aa-82a1-5cae7b3c487d","html_url":"https://github.com/JOKR-Services/logr-node","commit_stats":null,"previous_names":["jokr-services/logr-node"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JOKR-Services%2Flogr-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JOKR-Services%2Flogr-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JOKR-Services%2Flogr-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JOKR-Services%2Flogr-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JOKR-Services","download_url":"https://codeload.github.com/JOKR-Services/logr-node/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253948333,"owners_count":21988953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decorator","exception-handler","log","logger","node"],"created_at":"2025-05-13T12:55:35.496Z","updated_at":"2025-10-16T19:47:26.841Z","avatar_url":"https://github.com/JOKR-Services.png","language":"TypeScript","readme":"# `@daki/logr` - A Library for Standardizing Logs\n\n## Overview\n\nThis TypeScript log standardization library offers an easy and flexible way to standardize your application's logs.\nIt offers the ability to customize the logging behavior of exceptions, transactions and validations, allowing you to adapt the library to the specific needs of your project.\n\n## Installation\n\nTo start using `@daki/logr`, you can install it via npm or yarn:\n\n```bash\nnpm install @daki/logr\n# or\nyarn add @daki/logr\n```\n\n## Main features\n- Catch Exception\n- Catch Transaction [TODO]\n\n### Catch exception\nWe provide two ways to catch exceptions:\n- the `CatchException` decorator to use in your methods\n- the `catchException` function so that you don't have to use classes to use the library\n\n#### Configuration options\n| Option              | Type                | Required/Optional | Default value | Description                                                                                                                                                                                                        | Example using function                                                                                                          | Example using decorator                                                                                                           |\n|---------------------|---------------------|-------------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| bubbleException     | boolean             | Optional          | true          | If set to true, the original exception will be thrown after logging, allowing the exception to continue its propagation.                                                                                           | [Function](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/bubble-exception.function.md)      | [Decorator](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/bubble-exception.decorator.md)      |\n| customErrorInstance | object or function  | Optional          | null          | Allows you to specify a custom error instance to be thrown, useful for customizing the exception that is logged.                                                                                                   | [Function](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/custom-error-instance.function.md) | [Decorator](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/custom-error-instance.decorator.md) |\n| hideParams          | boolean             | Optional          | false         | If set to true, the parameters that have been passed to the method will not be recorded, keeping sensitive data private.                                                                                           | [Function](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/hide-params.function.md)           | [Decorator](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/hide-params.decorator.md)           |\n| isSync              | boolean             | Optional          | false         | Defines whether the method is synchronous, indicating whether or not it waits for responses from external calls.                                                                                                   |                                                                                                                                 |                                                                                                                                   |\n| kind                | string              | Optional          | null          | Defines the type of exception to be logged, allowing exceptions to be categorized into different groups or contexts.                                                                                               |                                                                                                                                 |                                                                                                                                   |\n| onException         | function            | Optional          | null          | It allows you to provide a custom function to handle the registered exception, executing specific actions when an exception occurs.                                                                                | [Function](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/on-exception.function.md)          | [Decorator](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/on-exception.decorator.md)          |\n| pipeParams          | function            | Optional          | null          | It allows you to use a function to process and transform the parameters before they are recorded, adapting them to the desired format.                                                                             | [Function](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/pipe-params.function.md)           | [Decorator](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/pipe-params.decorator.md)           |\n| returnOnException   | function            | Optional          | null          | It offers the ability to provide a custom function to handle the logged exception and return new information or values after the exception has been logged.                                                        | [Function](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/return-on-exception.function.md)   | [Decorator](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/return-on-exception.decorator.md)   |    \n| typeErrorHandling   | \"LOG\" or \"REGISTER\" | Optional          | \"LOG\"         | Defines the type of exception handling to be applied: LOG or REGISTER. If set to LOG, the exception will be logged. If set to REGISTER, the exception will be logged in the service to be logged in higher layers. | [Function](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/type-error-handling.function.md)   | [Decorator](https://github.com/JOKR-Services/logr-node/blob/main/doc/examples/catch-exception/type-error-handling.decorator.md)   |\n#### Basic usage\n##### Decorator:\n```typescript\nimport { CatchException } from '@daki/logr';\n\nexport class UserController {\n  @CatchException({\n    kind: 'Application',\n  })\n  public async getById(id: string) {\n    // Your logic for getting a user\n  }\n}\n```\n\n##### Function:\n```typescript\nimport { catchException } from '@daki/logr';\n\nexport const getUserById = catchException(async (id: string) =\u003e {\n  // Your logic for getting a user\n}, {\n  kind: 'Application',\n});\n```\n\n```typescript\nimport { catchException, CatchExceptionOptions } from '@daki/logr';\n\nconst options: CatchExceptionOptions = {\n  kind: 'Application',\n}\n\nasync function handleGetUserById(id: string) {\n  // Your logic for getting a user\n}\n\nexport const getUserById = catchException(handleGetUserById, options);\n```\n\n#### Log output\n```text\nUser is blocked {\n  \"timestamp\": \"2023-09-12T22:45:13.468Z\",\n  \"logger\": {\n    \"name\": \"UserController\",\n    \"method_name\": \"getById\",\n    \"params\": [\"c4baf266-13c9-4d6e-93a7-ff8dccde0905\"],\n  },\n  \"error\": {\n    \"name\": \"UserServiceError\",\n    \"message\": \"User is blocked\",\n    \"stack\": {ErrorStack},\n    \"kind\": \"Application\"\n  }\n}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjokr-services%2Flogr-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjokr-services%2Flogr-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjokr-services%2Flogr-node/lists"}