{"id":17154713,"url":"https://github.com/antoine-pous/npmlogger","last_synced_at":"2025-04-13T13:02:51.176Z","repository":{"id":85635167,"uuid":"80951748","full_name":"antoine-pous/npmlogger","owner":"antoine-pous","description":"Write your logs natively from npmlog with minor changes in your application","archived":false,"fork":false,"pushed_at":"2017-08-06T20:16:05.000Z","size":24,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T04:07:41.898Z","etag":null,"topics":["logfile","logger","logging","nodejs","npm","npmlog","npmlogger","rotate"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/npmlogger","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antoine-pous.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2017-02-04T22:06:28.000Z","updated_at":"2017-08-28T09:52:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"d3d5f75d-e961-4c3e-b802-57df31a976ff","html_url":"https://github.com/antoine-pous/npmlogger","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":0.06060606060606055,"last_synced_commit":"7e030a5f740e76bb804d1720cee7cb6d182d5deb"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoine-pous%2Fnpmlogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoine-pous%2Fnpmlogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoine-pous%2Fnpmlogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoine-pous%2Fnpmlogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antoine-pous","download_url":"https://codeload.github.com/antoine-pous/npmlogger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717251,"owners_count":21150389,"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":["logfile","logger","logging","nodejs","npm","npmlog","npmlogger","rotate"],"created_at":"2024-10-14T21:49:49.842Z","updated_at":"2025-04-13T13:02:51.153Z","avatar_url":"https://github.com/antoine-pous.png","language":"TypeScript","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=MAKZLQGRSBCT2"],"categories":[],"sub_categories":[],"readme":"npmlogger\n===========\n\n[![Build Status](https://travis-ci.org/antoine-pous/npmlogger.svg?branch=master)](https://travis-ci.org/antoine-pous/npmlogger)\n[![Dependency Status](https://img.shields.io/gemnasium/antoine-pous/npmlogger.svg)](https://gemnasium.com/antoine-pous/npmlogger)\n[![Donate](https://img.shields.io/badge/%E2%99%A5-donate-459042.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=MAKZLQGRSBCT2)\n\nNPM Logger is a package designed to write easily your log files. For more convenience npmlogger extends npmlog, so you can use it\nwith minor changes in your application code.\n\n## Installation\n\n```console\nnpm install npmlogger --save\n```\n\n## Basic Usage\n```javascript\n// Call npmlogger instead of npmlog\nvar log = require('npmlogger');\n\n// Set the log level required to be written\nlog.fileLevel = 'warn';\n\n// Set the basepath for log files\nlog.fileBasePath = './logs';\n\n// Set the filename\nlog.fileName = 'mylog.log';\n\n// write error log to mylog.log\nlog.info('My prefix', 'i am info'); // Displayed but not written\nlog.error('My prefix', 'i am error'); // Displayed and written\n```\n\nOutput :\n```txt\n[Fri Feb 03 2017 18:14:44 GMT+0100 (CET)] [error] [My prefix] i am error\n```\n\n## Configuration\n\n**Note:** All npmlogger methods and variables start with `file`.\n\n### log.fileName\n\n* {String}\n\nThe file name, `.log` extension is automaticly added at the end of name.\n\n### log.fileBasePath\n\n* {String}\n\nThe base path for the logs file, by default this is the `logs` directory related to the executed file.\n\n### log.fileCreatePath\n\n* {Bool}\n\nWhen this feature is enabled, the path is automaticly created. Use [mkpath](https://www.npmjs.com/package/mkpath) package.\n\n### log.fileLevel\n\n* {String}\n\nThe level to write logs. Any logs at or above this level will be written. The special level `silent` will prevent anything from being logged ever.\n\n### log.fileColor\n\n* {Bool}\n\nBy default npmlogger remove all console colors from file. You can allow colors by setting this option to true.\n\n### log.fileMaxSize\n\n* {Number}\n\nSet the max size for the log file, when the limit is reached the file is moved and a new one is created. The size is exprimed in `kilobyte`. The new file is\nnamed `mylog_1.log` or `mylog_error_1.log` if you enable [log.fileLevelSuffix][3].\n\n### log.fileDatePrefix\n\n* {String} See [dateformat](https://www.npmjs.com/package/dateformat) documentation\n\nThis option allow you to prefix the filename with your own date format.\n\n**Note:** The date prefix is always put **before** [log.fileHeadPrefix][4].\n\n### log.fileHeadPrefix\n\n* {Bool}\n\nThis option allow you to prefix the files with the [log.heading][1] value like `heading_mylog.log`.\n\n**Important** It is highly recommended to use slug keyword for [log.heading][1] or enable [log.fileSlugify][2] when [log.fileHeadPrefix][4] is enabled.\n\n### log.fileLevelSuffix\n\n* {Bool}\n\nThis option create seperated log file for each log level. So you can have `mylog_error.log`, `mylog_warn.log`, `mylog_info.log` etc...\n\n**Important** It is highly recommended to use slug keyword for custom level or enable [log.fileSlugify][2] when [log.fileLevelSuffix][3] is enabled.\n\n### log.fileSlugify\n\n* {Bool}\n\nWhen this feature is enabled the filename is slugified using [RCF3986](https://www.ietf.org/rfc/rfc3986.txt) standard.\n\n### log.fileEntriesTemplate\n\n* {Bool}\n\nWhen disabled this option remove the current default template and let you decide how to manage your entries.\n\n**Note:** The template is `[date] [level] [prefixes] error`, when disabled you only have `prefix error`.\n\n## Bug \u0026 suggestions\nIf you have any suggestions or found a bug feel free to use the [tracker](https://github.com/antoine-pous/npmlogger/issues).\n\n[1]: https://github.com/npm/npmlog#logheading\n[2]: #logfileslugify\n[3]: #logfilelevelsuffix\n[4]: #logfileheadprefix\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoine-pous%2Fnpmlogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantoine-pous%2Fnpmlogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoine-pous%2Fnpmlogger/lists"}