1.0.12 • Published 1 year ago

indexdb-log v1.0.12

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

indexdb-log

This is a small logger implemented with index-db, originally based on idb.

Install

npm install indexdb-log

Usage

Set log

import  IDBLog from 'indexdb-log'

const logger = new IDBLog(config)

logger.setLog('ERROR', { hello: 'world' })

// Same as logger.setLog('INFO', { hello: 'world' })
logger.info({ hello: 'world' })

// Same as logger.setLog('ERROR', { hello: 'world' })
logger.error({ hello: 'world' })

// Same as logger.setLog('WARN', { hello: 'world' })
logger.warn({ hello: 'world' })

Create logger config

NameDescriptionTypeDefault
dbNameThe name of indexdb database.stringlog-store
logStoreNameThe name of log store in a database.stringlogs
metaStoreNameThe name of meta data store in a database.stringmeta
countKeyThe name of key which store logs counts.stringlog-count
dbVersionVersion of database.number1
excludeA function to determine whether set a log or not, and return a boolean value.function() => false
durationThe number of seconds to keep logs, the expired logs will be dropped.number2 days (60 1000 60 24 2)
maxCountMax counts of logs. Oldest logs will be dropped when reached max count.number40 thousand
consoleLogPrint console log or not when set logbooleanfalse

Save log files

<button
    onClick={() => logger.saveLogFile(config)}
>
    download logs
</button>

Save logs config

NameDescriptionTypeDefault
titleThe name of log file.stringLogs${CurrentTimestamp}.txt
genLogA function to create log files format.function
1.0.12

1 year ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago