{"id":20958328,"url":"https://github.com/aiteq/trace","last_synced_at":"2025-05-14T06:32:04.286Z","repository":{"id":57095821,"uuid":"93203084","full_name":"aiteq/trace","owner":"aiteq","description":"TypeScript decorator to trace method calls using https://github.com/visionmedia/debug","archived":false,"fork":false,"pushed_at":"2017-06-03T19:45:29.000Z","size":7,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-01T20:17:47.910Z","etag":null,"topics":["debug","logging","trace","typescript"],"latest_commit_sha":null,"homepage":null,"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/aiteq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-02T20:53:09.000Z","updated_at":"2023-05-23T18:16:24.000Z","dependencies_parsed_at":"2022-08-22T21:40:32.165Z","dependency_job_id":null,"html_url":"https://github.com/aiteq/trace","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiteq%2Ftrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiteq%2Ftrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiteq%2Ftrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aiteq%2Ftrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aiteq","download_url":"https://codeload.github.com/aiteq/trace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254084656,"owners_count":22011918,"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":["debug","logging","trace","typescript"],"created_at":"2024-11-19T01:46:39.471Z","updated_at":"2025-05-14T06:31:59.270Z","avatar_url":"https://github.com/aiteq.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# trace\n[![Build Status](https://travis-ci.org/aiteq/trace.svg?branch=master)](https://travis-ci.org/aiteq/trace)\n\nTypeScript decorator to trace method calls using https://github.com/visionmedia/debug\n\n## Installation\n\n```bash\n$ npm install @aiteq/trace\n```\n\n## Usage\nThe `Trace` decorator can be used for classes as well as for methods.\n\n### Decorating a class:\n```ts\nimport { Trace } from \"@aiteq/trace\";\n\n@Trace()\nclass User {\n  constructor(public name: string) { }\n  \n  public getName(): string {\n    return this.name;\n  }\n  \n  public toString(): string {\n    return this.getName();\n  }\n}\n\nconsole.log(new User(\"Honza\").toString());\n```\nThe output would look like this:\n```\n\u003e DEBUG=* node ./dist/trace-test.js\n\n  TRACE =\u003e User.toString() +0ms\n  TRACE =\u003e User.getName() +5ms\n  TRACE \u003c= User.getName: Honza +6ms\n  TRACE \u003c= User.toString: Honza +7ms\nHonza\n```\n\n### Decorating a method:\n```ts\nimport { Trace } from \"@aiteq/trace\";\n\nclass User {\n  constructor(public name: string) { }\n  \n  @Trace()\n  public getName(): string {\n    return this.name;\n  }\n  \n  public toString(): string {\n    return this.getName();\n  }\n}\n\nconsole.log(new User(\"Honza\").toString());\n```\nThe output would look like this:\n```\n\u003e DEBUG=* node ./dist/trace-test.js\n\n  TRACE =\u003e User.getName() +0ms\n  TRACE \u003c= User.getName: Honza +5ms\nHonza\n```\n\n### Notes\n- While [decorators](https://www.typescriptlang.org/docs/handbook/decorators.html) are still experimental, you must set `experimentalDecorators` to `true` in your `tsconfig.json`.\n- The output is controlled by the `DEBUG` environment variable. All tracing records are prefixed with the `TRACE` string. So for enabling the tracing set the `DEBUG` variable to e.g. `TRACE` or `*`. See `debug`'s [doc](https://github.com/visionmedia/debug) for details.\n- The output will be colorized by `debug`.\n- Tracing doesn't work for constructors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiteq%2Ftrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faiteq%2Ftrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiteq%2Ftrace/lists"}