Socket
Socket
Sign inDemoInstall

fsp-pouch-logger

Package Overview
Dependencies
80
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fsp-pouch-logger

# Usage


Version published
Maintainers
1
Created

Readme

Source

fsp-pouchdb-logger

Usage

const { UniLogger } = require('fsp-pouchdb-logger')

function sleep(ms) {
    return new Promise((resolve,reject)=>{
        setTimeout(() => {
            resolve()
        }, ms);
    })
}

async function insert() {
    // 创建连接
    const logger = new UniLogger('test',{
        server: 'http://admin:password@remotehost:5984/logger_db',  // 定义了远程服务器则会自动同步日志到服务器
        debug: true,
        timeTagMode: 'minute',  // 为了演示按时间自动创建本地库的功能而设置,生产环境下可设置为 hour 或者 day,默认为 day
        keepLastN: 3,           // 保留最近的 N 个本地库
    })
    // 插入数据
    for(let i=0; i<200; i++) {
        await sleep(2000)
        await logger.write({
            _id: 'test' + Math.random(),
            logLevel: '事件',
            logType: '测试',
            fromApp: 'MP',
            opType: '新增用户',
            operator: 'admin',
            description: '这就是一个测试' + (i+1),
            info: {},
            createdAt: new Date()
        })
    }
}

insert()

FAQs

Last updated on 27 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc