A plugin that stores logs in browser memory and allows them to be downloaded as a file

import { Logger, DOMFilePlugin } from "@koadz/logger";

const domPlugin = new DOMFilePlugin({
maxLogSize: 1000, // Maximum number of logs to keep in memory
});

const Log = new Logger();
Log.registerPlugin(domPlugin);

// Usage
Log.i("Stored in browser memory");
Log.e("Error stored in browser memory");

// Download logs
domPlugin.downloadLogs("all", "my-app-logs.log"); // All logs
domPlugin.downloadLogs("errors", "error-logs.log"); // Only errors

// Get logs programmatically
const allLogs = domPlugin.getLogs();
const errorLogs = domPlugin.getLogs("errors");

// Clear logs
domPlugin.clearLogs(); // Clear all logs
domPlugin.clearLogs("errors"); // Clear only errors

Implements

Constructors

Properties

name: "DOMFilePlugin"

The name of the plugin

BasePlugin

Methods

  • Clears browser logs from memory

    Parameters

    • type: DownloadLogType = 'all'

      The type of logs to clear. Default all

    Returns void

    DOMFilePlugin

  • Downloads logs as a file in browser environment

    Parameters

    • type: DownloadLogType = 'all'

      The type of logs to download. Default all

    • Optionalfilename: string

      The custom filename

    Returns void

    DOMFilePlugin

  • Gets current logs stored in browser memory

    Parameters

    • type: DownloadLogType = 'all'

      The type of logs to retrieve. Default all

    Returns string[]

    DOMFilePlugin