Nightly Perpetrated Mischief

    @obsidize/rotating-file-stream
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.2 • Public • Published

    @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.

    Installation

    • npm:
    npm install --save @obsidize/rotating-file-stream

    Usage

    1. Create A RotationFileStream instance:
    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']
    	)
    });
    1. Write to the stream:
    const buffer = new ArrayBuffer(42);
    fileStream.write(buffer).then(...);

    Thats it!

    See the Ionic App Example for working sample code.

    API

    Source documentation can be found here

    Install

    npm i @obsidize/rotating-file-stream

    DownloadsWeekly Downloads

    55

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    26.3 kB

    Total Files

    15

    Last publish

    Collaborators

    • jospete