{"action":"created","issue":{"url":"https://api.github.com/repos/visionmedia/debug/issues/544","repository_url":"https://api.github.com/repos/visionmedia/debug","labels_url":"https://api.github.com/repos/visionmedia/debug/issues/544/labels{/name}","comments_url":"https://api.github.com/repos/visionmedia/debug/issues/544/comments","events_url":"https://api.github.com/repos/visionmedia/debug/issues/544/events","html_url":"https://github.com/visionmedia/debug/pull/544","id":290969259,"node_id":"MDExOlB1bGxSZXF1ZXN0MTY0NjcxODU2","number":544,"title":"introduce `debug.unique()`","user":{"login":"indutny","id":238531,"node_id":"MDQ6VXNlcjIzODUzMQ==","avatar_url":"https://avatars3.githubusercontent.com/u/238531?v=4","gravatar_id":"","url":"https://api.github.com/users/indutny","html_url":"https://github.com/indutny","followers_url":"https://api.github.com/users/indutny/followers","following_url":"https://api.github.com/users/indutny/following{/other_user}","gists_url":"https://api.github.com/users/indutny/gists{/gist_id}","starred_url":"https://api.github.com/users/indutny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indutny/subscriptions","organizations_url":"https://api.github.com/users/indutny/orgs","repos_url":"https://api.github.com/users/indutny/repos","events_url":"https://api.github.com/users/indutny/events{/privacy}","received_events_url":"https://api.github.com/users/indutny/received_events","type":"User","site_admin":false},"labels":[{"id":481435483,"node_id":"MDU6TGFiZWw0ODE0MzU0ODM=","url":"https://api.github.com/repos/visionmedia/debug/labels/change-minor","name":"change-minor","color":"c5def5","default":false},{"id":481434813,"node_id":"MDU6TGFiZWw0ODE0MzQ4MTM=","url":"https://api.github.com/repos/visionmedia/debug/labels/discussion","name":"discussion","color":"c2e0c6","default":false},{"id":481434865,"node_id":"MDU6TGFiZWw0ODE0MzQ4NjU=","url":"https://api.github.com/repos/visionmedia/debug/labels/feature","name":"feature","color":"006b75","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-01-23T19:45:54Z","updated_at":"2018-12-13T15:53:07Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/visionmedia/debug/pulls/544","html_url":"https://github.com/visionmedia/debug/pull/544","diff_url":"https://github.com/visionmedia/debug/pull/544.diff","patch_url":"https://github.com/visionmedia/debug/pull/544.patch"},"body":"When debugging the applications that work with pools of streams\r\nor sockets, the debug stream often comes out interleaved making it\r\nimpossible to distinguish between streams. It is a common knowledge\r\nthat unique ids could be assigned to each stream and be used in\r\nlogging to solve this. However, this solution is rather ad-hoc and\r\nusually applied only during manual debugging.\r\n\r\nIntroduce `debug.unique([ format ])` method that returns function with\r\nthe same signature as `debug`. This function however prepends either\r\n`'%d '` or `format + ' '` (depending on the presence of `format`) to the\r\nfirst argument of original `debug` function, and supplies unique\r\ninteger as a second argument, shifting the rest to the right.\r\n\r\nExample:\r\n\r\n```\r\nconst debug = require('debug')('ns');\r\n\r\nclass Instance {\r\n  constructor() {\r\n    this.debug = debug.unique('id=%d ');\r\n  }\r\n\r\n  method() {\r\n    this.debug('method data=%j', {});\r\n    // \"id=123 method data={}\"\r\n  }\r\n\r\n  attach(other) {\r\n    this.debug('attach to=%d', other.debug.id());\r\n    // \"id=123 attach to=456\"\r\n  }\r\n}\r\n```\r\n\r\n---\r\n\r\nAlternative to https://github.com/visionmedia/debug/pull/543"},"comment":{"url":"https://api.github.com/repos/visionmedia/debug/issues/comments/447018584","html_url":"https://github.com/visionmedia/debug/pull/544#issuecomment-447018584","issue_url":"https://api.github.com/repos/visionmedia/debug/issues/544","id":447018584,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzAxODU4NA==","user":{"login":"Qix-","id":885648,"node_id":"MDQ6VXNlcjg4NTY0OA==","avatar_url":"https://avatars2.githubusercontent.com/u/885648?v=4","gravatar_id":"","url":"https://api.github.com/users/Qix-","html_url":"https://github.com/Qix-","followers_url":"https://api.github.com/users/Qix-/followers","following_url":"https://api.github.com/users/Qix-/following{/other_user}","gists_url":"https://api.github.com/users/Qix-/gists{/gist_id}","starred_url":"https://api.github.com/users/Qix-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qix-/subscriptions","organizations_url":"https://api.github.com/users/Qix-/orgs","repos_url":"https://api.github.com/users/Qix-/repos","events_url":"https://api.github.com/users/Qix-/events{/privacy}","received_events_url":"https://api.github.com/users/Qix-/received_events","type":"User","site_admin":false},"created_at":"2018-12-13T15:53:07Z","updated_at":"2018-12-13T15:53:07Z","author_association":"MEMBER","body":"I see the point now, @indutny - not sure why I wasn't getting it the last time I looked at this.\r\n\r\nQuestion is, why not just use another namespace? `.extend()` was added in #524 for similar reasons - using wildcards in namespaces should do something similar, if not the same.\r\n\r\nAlso, sorry for taking so long to get back to this."}}
{"actor":{"display_login":"Qix-"}}