{"id":18278196,"url":"https://github.com/log4js-node/streamroller","last_synced_at":"2025-04-05T01:09:16.457Z","repository":{"id":38801928,"uuid":"12453736","full_name":"log4js-node/streamroller","owner":"log4js-node","description":"node.js file streams that roll over when they reach a maximum size, or a date/time.","archived":false,"fork":false,"pushed_at":"2024-01-25T01:56:56.000Z","size":1200,"stargazers_count":37,"open_issues_count":6,"forks_count":19,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-26T01:43:20.880Z","etag":null,"topics":["javascript","stream"],"latest_commit_sha":null,"homepage":null,"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/log4js-node.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":"2013-08-29T07:05:42.000Z","updated_at":"2024-06-18T13:33:40.175Z","dependencies_parsed_at":"2024-01-25T02:51:18.409Z","dependency_job_id":"ceea9fc2-0ee8-4713-89aa-998dd648f693","html_url":"https://github.com/log4js-node/streamroller","commit_stats":{"total_commits":347,"total_committers":15,"mean_commits":"23.133333333333333","dds":0.4726224783861671,"last_synced_commit":"16514b11c388e4b8b31c435ed59e5dadd18b9950"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2Fstreamroller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2Fstreamroller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2Fstreamroller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2Fstreamroller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/log4js-node","download_url":"https://codeload.github.com/log4js-node/streamroller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247271532,"owners_count":20911587,"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":["javascript","stream"],"created_at":"2024-11-05T12:23:26.246Z","updated_at":"2025-04-05T01:09:16.442Z","avatar_url":"https://github.com/log4js-node.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"streamroller [![CodeQL](https://github.com/log4js-node/streamroller/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/log4js-node/streamroller/actions/workflows/codeql-analysis.yml) [![Node.js CI](https://github.com/log4js-node/streamroller/actions/workflows/node.js.yml/badge.svg)](https://github.com/log4js-node/streamroller/actions/workflows/node.js.yml)\n============\n\n[![NPM](https://nodei.co/npm/streamroller.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/streamroller/)\n\nnode.js file streams that roll over when they reach a maximum size, or a date/time.\n\n```sh\nnpm install streamroller\n```\n\n## usage\n\n```javascript\nvar rollers = require('streamroller');\nvar stream = new rollers.RollingFileStream('myfile', 1024, 3);\nstream.write(\"stuff\");\nstream.end();\n```\n\nThe streams behave the same as standard node.js streams, except that when certain conditions are met they will rename the current file to a backup and start writing to a new file.\n\n### new RollingFileStream(filename [, maxSize, numBackups, options])\n* `filename` \\\u003cstring\\\u003e\n* `maxSize` \\\u003cinteger\\\u003e - defaults to `0` - the size in bytes to trigger a rollover. If not specified or 0, then no log rolling will happen.\n* `numBackups` \\\u003cinteger\\\u003e - defaults to `1` - the number of old files to keep (excluding the hot file)\n* `options` \\\u003cObject\\\u003e\n  * `encoding` \\\u003cstring\\\u003e - defaults to `'utf8'`\n  * `mode` \\\u003cinteger\\\u003e - defaults to `0o600` (see [node.js file modes](https://nodejs.org/dist/latest-v12.x/docs/api/fs.html#fs_file_modes))\n  * `flags` \\\u003cstring\\\u003e - defaults to `'a'` (see [node.js file flags](https://nodejs.org/dist/latest-v12.x/docs/api/fs.html#fs_file_system_flags))\n  * `compress` \\\u003cboolean\\\u003e - defaults to `false` - compress the backup files using gzip (backup files will have `.gz` extension)\n  * `keepFileExt` \\\u003cboolean\\\u003e - defaults to `false` - preserve the file extension when rotating log files (`file.log` becomes `file.1.log` instead of `file.log.1`).\n  * `fileNameSep` \\\u003cstring\\\u003e - defaults to `'.'` - the filename separator when rolling. e.g.: abc.log`.`1 or abc`.`1.log (keepFileExt)\n\nThis returns a `WritableStream`. When the current file being written to (given by `filename`) gets up to or larger than `maxSize`, then the current file will be renamed to `filename.1` and a new file will start being written to. Up to `numBackups` of old files are maintained, so if `numBackups` is 3 then there will be 4 files:\n\u003cpre\u003e\n     filename\n     filename.1\n     filename.2\n     filename.3\n\u003c/pre\u003e\nWhen filename size \u003e= maxSize then:\n\u003cpre\u003e\n     filename -\u003e filename.1\n     filename.1 -\u003e filename.2\n     filename.2 -\u003e filename.3\n     filename.3 gets overwritten\n     filename is a new file\n\u003c/pre\u003e\n\n### new DateRollingFileStream(filename [, pattern, options])\n* `filename` \\\u003cstring\\\u003e\n* `pattern` \\\u003cstring\\\u003e - defaults to `yyyy-MM-dd` - the date pattern to trigger rolling (see below)\n* `options` \\\u003cObject\\\u003e\n  * `encoding` \\\u003cstring\\\u003e - defaults to `'utf8'`\n  * `mode` \\\u003cinteger\\\u003e - defaults to `0o600` (see [node.js file modes](https://nodejs.org/dist/latest-v12.x/docs/api/fs.html#fs_file_modes))\n  * `flags` \\\u003cstring\\\u003e - defaults to `'a'` (see [node.js file flags](https://nodejs.org/dist/latest-v12.x/docs/api/fs.html#fs_file_system_flags))\n  * `compress` \\\u003cboolean\\\u003e - defaults to `false` - compress the backup files using gzip (backup files will have `.gz` extension)\n  * `keepFileExt` \\\u003cboolean\\\u003e - defaults to `false` - preserve the file extension when rotating log files (`file.log` becomes `file.2017-05-30.log` instead of `file.log.2017-05-30`).\n  * `fileNameSep` \\\u003cstring\\\u003e - defaults to `'.'` - the filename separator when rolling. e.g.: abc.log`.`2013-08-30 or abc`.`2013-08-30.log (keepFileExt)\n  * `alwaysIncludePattern` \\\u003cboolean\\\u003e - defaults to `false` - extend the initial file with the pattern\n  * \u003cstrike\u003e`daysToKeep`\u003c/strike\u003e `numBackups` \\\u003cinteger\\\u003e - defaults to `1` - the number of old files that matches the pattern to keep (excluding the hot file)\n  * `maxSize` \\\u003cinteger\\\u003e - defaults to `0` - the size in bytes to trigger a rollover. If not specified or 0, then no log rolling will happen.\n\nThis returns a `WritableStream`. When the current time, formatted as `pattern`, changes then the current file will be renamed to `filename.formattedDate` where `formattedDate` is the result of processing the date through the pattern, and a new file will begin to be written. Streamroller uses [date-format](http://github.com/nomiddlename/date-format) to format dates, and the `pattern` should use the date-format format. e.g. with a `pattern` of `\"yyyy-MM-dd\"`, and assuming today is August 29, 2013 then writing to the stream today will just write to `filename`. At midnight (or more precisely, at the next file write after midnight), `filename` will be renamed to `filename.2013-08-29` and a new `filename` will be created. If `options.alwaysIncludePattern` is true, then the initial file will be `filename.2013-08-29` and no renaming will occur at midnight, but a new file will be written to with the name `filename.2013-08-30`. If `maxSize` is populated, when the current file being written to (given by `filename`) gets up to or larger than `maxSize`, then the current file will be renamed to `filename.pattern.1` and a new file will start being written to. Up to `numBackups` of old files are maintained, so if `numBackups` is 3 then there will be 4 files:\n\u003cpre\u003e\n     filename\n     filename.20220131.1\n     filename.20220131.2\n     filename.20220131.3\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flog4js-node%2Fstreamroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flog4js-node%2Fstreamroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flog4js-node%2Fstreamroller/lists"}