{"id":30699667,"url":"https://github.com/mohsen-d/commentlogger","last_synced_at":"2026-05-17T06:37:44.456Z","repository":{"id":37479765,"uuid":"504679100","full_name":"mohsen-d/commentlogger","owner":"mohsen-d","description":"Logging module for nodejs using comments","archived":false,"fork":false,"pushed_at":"2022-06-21T14:50:27.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-26T02:20:40.717Z","etag":null,"topics":["comments","logging","logging-library","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/mohsen-d.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":"2022-06-17T21:43:09.000Z","updated_at":"2022-06-21T15:03:19.000Z","dependencies_parsed_at":"2022-09-14T12:20:45.787Z","dependency_job_id":null,"html_url":"https://github.com/mohsen-d/commentlogger","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mohsen-d/commentlogger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fcommentlogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fcommentlogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fcommentlogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fcommentlogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohsen-d","download_url":"https://codeload.github.com/mohsen-d/commentlogger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fcommentlogger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272962437,"owners_count":25022688,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["comments","logging","logging-library","nodejs"],"created_at":"2025-09-02T11:12:05.165Z","updated_at":"2025-10-15T16:12:22.334Z","avatar_url":"https://github.com/mohsen-d.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# commentlogger\n\ncommentlogger enables developers to move their debugging console.log() out of their code and into the comments, resulting in a cleaner code.\n\n## installing\n\ninstall using `npm i commentlogger`\n\n## using\n\n    const logger = require('commentlogger');\n    logger.watch(() =\u003e {\n        module content ...\n    })();\n\nwherever a log is required, add a `//` , then add `log(message, env)`\n\nThe following logs `sum` when `NODE_ENV` is set to `dev`:\n\n    const sum = 3 + 2; // log(sum, dev)\n\nThis one will run if the environment is set to `prod`:\n\n    const result = calculateSomething(); // log(result, prod)\n\nMultiple `env` can be set:\n\n    const result = calculateSomething(); // log(result, dev, test)\n\nif `env` is not provided, logging will be done regardless of `NODE_ENV` value;\n\n    const sum = 3 + 2; // log(sum)\n\nIt is not limited to logging variables. You can put messages to be logged\n\n    throw new Error(\"something went wrong\"); // log(\"an error occurred\");\n\n## defining custom logging behavior\n\nBy default, `console.log` is used by the library. But a custom logic can be set as the second argument of `watch()` function\n\n    const logger = require('commentlogger');\n    logger.watch(() =\u003e {\n        module content ...\n    }, (msg) =\u003e someCustomFunction(msg))();\n\nThe example below writes logs to a file:\n\n    const logger = require(\"commentlogger\");\n    const fs = require(\"fs\");\n\n    function writeToFile(msg) {\n        fs.appendFile(\"file.log\", msg.toString() + \"\\n\", (err) =\u003e {\n            if (err) {\n              console.error(err);\n            }\n        });\n    }\n\n    logger.watch(() =\u003e {\n        module content....\n    },\n        (msg) =\u003e writeToFile(msg)\n    )();\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohsen-d%2Fcommentlogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohsen-d%2Fcommentlogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohsen-d%2Fcommentlogger/lists"}