{"id":15595449,"url":"https://github.com/cdimascio/bunyan-decorator","last_synced_at":"2025-03-29T11:28:35.239Z","repository":{"id":57191628,"uuid":"82990670","full_name":"cdimascio/bunyan-decorator","owner":"cdimascio","description":"bunyan log decorator for es6 class methods","archived":false,"fork":false,"pushed_at":"2017-03-13T17:45:09.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T03:09:42.651Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdimascio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-24T02:00:55.000Z","updated_at":"2019-03-26T20:26:25.000Z","dependencies_parsed_at":"2022-09-01T03:22:29.529Z","dependency_job_id":null,"html_url":"https://github.com/cdimascio/bunyan-decorator","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/cdimascio%2Fbunyan-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fbunyan-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fbunyan-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fbunyan-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdimascio","download_url":"https://codeload.github.com/cdimascio/bunyan-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246177318,"owners_count":20735945,"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":[],"created_at":"2024-10-03T01:00:23.490Z","updated_at":"2025-03-29T11:28:35.213Z","avatar_url":"https://github.com/cdimascio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#bunyan-decorator\n\n**bunyan-decorator** enables you to log the result of functions that return a promise or a value.\n\n \n## Install\n\n`npm install bunyan-decorator`\n\n## Usage\n\n```javascript\nconst bunyan = require('bunyan');\nconst bunyand = require ('./bunyan-decorator');\n\nconst l = new Logger(bunyan.createLogger({\n  name: 'my-app'\n}));\n\nconst log = l.log;\n\nclass MyClass {\n\n  // Decorator your class method to log it\n  @log(Level.info)\n  searchById(id) {\n    return MySearchService.byId(id);\n  }\n}\n```\n\n### Extractors\nExtractors enable you to modify the result logged by the bunyan decorator\n\n```javascript\nclass MyClass {\n\n  // This extractor will transform the result nil, thus not return value is logged\n  @log(Level.info, { extractor: result =\u003e {} })\n  searchById(id) {\n    return MySearchService.byId(id);\n  }\n}\n```\n\n## Example log record\n\nNote all log records include all default bunyan property as well as the class name, the class method, the elapsed time, and the result (unless an extractor is used).\n\n#### Pretty\n```\n02:12:41.894Z  INFO my-app: SchoolsService.all(...) (module=SchoolsService, method=all(...), elapsedTime=428.553181)\n    result: [\n      {\n        \"id\": \"sampleschoolid1\",\n        \"location\": {\n          \"geo\": {\n            \"lat\": -1,\n            \"lon\": -1\n          },\n          \"address\": {\n            \"street\": \"10 street rd\",\n            \"city\": \"littleton\",\n            \"state\": \"ma\",\n            \"zip\": \"01146\"\n          }\n        },\n        \"type\": \"school\",\n        \"name\": \"sampleschoolid1\",\n        \"district\": {\n          \"id\": \"district-1\",\n          \"name\": \"District One\",\n          \"type\": \"district\"\n        },\n        \"group\": {\n          \"name\": \"School Group One\"\n        },\n        \"created\": \"2017-02-16T13:36:01.781Z\"\n      }\n    ]\n```\n\n#### Raw\n```json\n\"name\":\"my-app\",\"hostname\":\"Carmines-MacBook-Pro-7.local\",\"pid\":58820,\"level\":30,\"module\":\"ExpressServer\",\"method\":\"listen\",\"msg\":\"up\n and running in development @: Carmines-MacBook-Pro-7.local on port: 3003}\",\"time\":\"2017-02-24T02:15:38.065Z\",\"v\":0}\n{\"name\":\"ecl-registration\",\"hostname\":\"Carmines-MacBook-Pro-7.local\",\"pid\":58820,\"level\":30,\"module\":\"SchoolsService\",\"method\":\"all(...)\",\"elaps\nedTime\":404.09158199999996,\"result\":[{\"id\":\"sampleschoolid1\",\"location\":{\"geo\":{\"lat\":-1,\"lon\":-1},\"address\":{\"street\":\"10 street rd\",\"city\":\"li\nttleton\",\"state\":\"ma\",\"zip\":\"01146\"}},\"type\":\"school\",\"name\":\"sampleschoolid1\",\"district\":{\"id\":\"district-1\",\"name\":\"District One\",\"type\":\"distr\nict\"},\"group\":{\"name\":\"School Group One\"},\"created\":\"2017-02-16T13:36:01.781Z\"}],\"msg\":\"SchoolsService.all(...)\",\"time\":\"2017-02-24T02:15:41.487\nZ\",\"v\":0}\n{\"name\":\"ecl-registration\",\"hostname\":\"Carmines-MacBook-Pro-7.local\",\"pid\":58820,\"level\":30,\"module\":\"Controller\",\"method\":\"all(...)\",\"elapsedTi\nme\":410.745346,\"msg\":\"Controller.all(...)\",\"time\":\"2017-02-24T02:15:41.494Z\",\"v\":0}\n```\n\n\n## License\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdimascio%2Fbunyan-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdimascio%2Fbunyan-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdimascio%2Fbunyan-decorator/lists"}