@etholog/sync-storage-transport
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

@etholog/sync-storage-transport

A transport that stores logs in synchronous storage like localStorage.

Installation

npm install @etholog/sync-storage-transport

Example usage

import { createLogger } from "etholog";
import { syncStorageTransport, createJSONStorage } from "@etholog/sync-storage-transport";

const logger = createLogger({
  transports: [
    syncStorageTransport({
      storage: createJSONStorage(() => localStorage),
      maxLogs: 1000,
    }),
  ],
});

logger.info("Hello world!");

Options

Option Type Default Description
storage SyncStorage N/A The storage to use. Required.
key string "ETHOLOG_STORAGE" The key to use for the storage.
maxLogs number undefined If set, it will limit the number of logs stored. Once the limit is reached, the oldest log will be removed.

Readme

Keywords

none

Package Sidebar

Install

npm i @etholog/sync-storage-transport

Weekly Downloads

56

Version

0.2.1

License

MIT

Unpacked Size

14.5 kB

Total Files

16

Last publish

Collaborators

  • koengommers