A rotating file stream based on the cordova File plugin API

Usage no npm install needed!

<script type="module">
  import obsidizeRotatingFileStream from 'https://cdn.skypack.dev/@obsidize/rotating-file-stream';



A cordova/ionic flavor for rotating file streams on mobile devices.

The primary goal of this module is to act as a transport outlet for @obsidize/rx-console, and to give an out-the-box working log-to-file solution for ionic mobile apps.

Note that while the intention of this module is for ionic app file logging, the actual implementation is written in pure typescript with no ionic / angular / cordova dependencies embedded in it.

So theoretically this could be used as middleware for any system that has a file API and can run javascript.

If you need a pure NodeJS implementation, use rotating-file-stream instead.


  • npm:
npm install --save @obsidize/rotating-file-stream
  • git:
npm install --save git+https://github.com/jospete/obsidize-rotating-file-stream.git


  1. Create A RotationFileStream instance:
import { RotatingFileStream, CordovaFileEntryApi } from '@obsidize/rotating-file-stream';

// NOTE: While CordovaFileEntryApi is used as an example here, 
// the 'files' option can be an array of anything that implements the FileEntryLike interface.
const fileStream = new RotatingFileStream({
    maxSize: 2000000, // 2MB
    files: CordovaFileEntryApi.createCacheRotationFiles(
        cdvFile, // @ionic-native/file reference
        ['debug-a.log', 'debug-b.log']
  1. Write to the stream:
const buffer = new ArrayBuffer(42);

Thats it!

See the Ionic App Example for working sample code.