# stream-file-archive

> Pipe Streams to time-rotated log files

Latest version **1.1.4** (published 2018-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install stream-file-archive
pnpm add stream-file-archive
yarn add stream-file-archive
bun add stream-file-archive
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2018-06-04 |
| First published | 2013-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Bryce B. Baril |
| Maintainers | bryce |
| Keywords | log, logging, logrotate, rotation, stream, streams, archive |

## Links

- npm: https://www.npmjs.com/package/stream-file-archive
- Repository: https://github.com/brycebaril/stream-file-archive
- Homepage: https://github.com/brycebaril/stream-file-archive#readme
- Issues: https://github.com/brycebaril/stream-file-archive/issues
- npm.io page: https://npm.io/package/stream-file-archive

## Dependencies (4)

- [xtend](https://npm.io/package/xtend.md) ~4.0.0
- [mkdirp](https://npm.io/package/mkdirp.md) ~0.5.0
- [ultra-strftime](https://npm.io/package/ultra-strftime.md) ^1.0.2
- [readable-stream](https://npm.io/package/readable-stream.md) ~1.0.33

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.1.4 (latest) — 2018-06-04
- 1.1.3 — 2015-11-04
- 1.1.2 — 2015-05-03
- 1.1.1 — 2014-06-04
- 1.1.0 — 2014-01-29
- 1.0.2 — 2013-09-26
- 1.0.1 — 2013-06-01
- 1.0.0 — 2013-06-01

## README

stream-file-archive
===================

[![NPM](https://nodei.co/npm/stream-file-archive.png)](https://nodei.co/npm/stream-file-archive/)

Easy log rotation for Node.js

Supports:
  * Output your logs to time-rotated log files.
  * Optionally gzip the logs once they are no longer current
  * Optionally maintain a symlink to the currently active log file
  * Native Streams2 (0.10.x+) with backwards compatibility

Can directly plug into [smart-tee](http://npm.im/smart-tee), e.g.:

```
node foo.js 2>&1 | smart-tee --s stdout --s stream-file-archive --path logs/app-%Y-%m-%d.log
```

Usage:
======

```javascript
var rotator = require("stream-file-archive")({
  path: "logs/app-%Y-%m-%d.log",  // Write logs rotated by the day
  symlink: "logs/current.log",    // Maintain a symlink called current.log
  compress: true,                 // Gzip old log files
})

my_logger_thingy.pipe(rotator)
```

Options
=======

path
----

A string file path with any of the below options to define rotation schedule:

e.g. `logs/mylog-%Y-%m-%d.log` would result in logs like `logs/mylog-2013-06-01.log`

  * %Y 4-digit year e.g. 2013
  * %y 2-digit year e.g. 13
  * %m month (01..12)
  * %d day of month (01..31)
  * %F iso8601 date portion (e.g. 2012-09-24)
  * %H hour (00..23)
  * %M minute (00..59)
  * %S second (00..61)
  * %T iso8601 time portion to the second (e.g.: 15:12:47)

See [strftime](https://www.npmjs.com/package/strftime) documentation for all specifiers.

symlink
-------

A path to a symlink that will be maintained to point at the current log file.

compress
--------

Boolean value, whether to gzip the files once they aren't being written to.

Events
---

Emits a `done` event when the source stream has finished and all file stream work is complete.

NOTES:
======

*Currently only timestamps files in UTC timezone.* Pull requests welcome!

LICENSE
=======

MIT

---
_Source: https://npm.io/package/stream-file-archive · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
