# @obsidize/rotating-file-stream

> A rotating file stream based on the cordova File plugin API

Latest version **1.2.3** (published 2023-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @obsidize/rotating-file-stream
pnpm add @obsidize/rotating-file-stream
yarn add @obsidize/rotating-file-stream
bun add @obsidize/rotating-file-stream
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2023-11-29 |
| First published | 2021-03-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Josh Noel |
| Maintainers | jospete |
| Keywords | cordova, ionic, file, stream, rotating, rotate, log, logger |

## Links

- npm: https://www.npmjs.com/package/@obsidize/rotating-file-stream
- Repository: https://github.com/jospete/obsidize-rotating-file-stream
- Homepage: https://github.com/jospete/obsidize-rotating-file-stream#readme
- Issues: https://github.com/jospete/obsidize-rotating-file-stream/issues
- npm.io page: https://npm.io/package/@obsidize/rotating-file-stream

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.1

## 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.2.3 (latest) — 2023-11-29
- 1.2.2 — 2022-04-13
- 1.2.1 — 2022-04-13
- 1.2.0 — 2022-04-12
- 1.1.0 — 2021-09-27
- 1.0.9 — 2021-09-25
- 1.0.8 — 2021-09-15
- 1.0.7 — 2021-09-15
- 1.0.6 — 2021-04-24
- 1.0.5 — 2021-04-24
- 1.0.4 — 2021-03-15
- 1.0.3 — 2021-03-15
- 1.0.2 — 2021-03-14
- 1.0.1 — 2021-03-14
- 1.0.0 — 2021-03-14

## README

# @obsidize/rotating-file-stream

Simple wrapper for streaming data to files on mobile devices in hybrid apps.

If you're using this for log capture on a cordova / capacitor app,
consider using [cordova-plugin-secure-logger](https://github.com/jospete/cordova-plugin-secure-logger) instead.

If you need a pure NodeJS implementation, use [rotating-file-stream](https://www.npmjs.com/package/rotating-file-stream) instead.

## Installation

- npm:

```bash
npm install --save @obsidize/rotating-file-stream
```

## API

Source documentation can be found [here](https://jospete.github.io/obsidize-rotating-file-stream/)

## Usage

1. Create A RotationFileStream instance:

```typescript
import { RotatingFileStream, CordovaFileEntryApi, CapacitorFileEntryApi } from '@obsidize/rotating-file-stream';

const fileStream = new RotatingFileStream({
	maxFileSize: 2e6, // 2MB
	files: CordovaFileEntryApi.createCacheRotationFiles(
		cdvFile, // @awesome-cordova-plugins/file reference
		'logs',
		['debug-a.log', 'debug-b.log']
	)
});

// Or if you want to use @capacitor/filesystem
const fileStream = new RotatingFileStream({
	maxFileSize: 2e6, // 2MB
	files: CapacitorFileEntryApi.createCacheRotationFiles(
		Filesystem, // @capacitor/filesystem reference
		'logs',
		['debug-a.log', 'debug-b.log']
	)
});
```

2. Write to the stream:

```typescript
const buffer = new ArrayBuffer(42);
fileStream.write(buffer).then(...);
```

3. Read data back later on:

```typescript
const entries = await fileStream.refreshAllEntries();

for (const entry of entries) {
	// read the entry data, or get its URL and do something with it
}
```

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