npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@netease-yunxin/log-storage

v1.0.5

Published

a log storage tool, support manual reporting

Downloads

68

Readme

log-storage的是什么

一个基于 IndexedDB 的本地日志存储工具。

它不包含上传功能,由使用者定义日志的上传,这也保证了它的纯粹和轻量

TODO

日志量变多后的一些问题

  • 分表存储
  • 分批查询

使用方式

const logger = new LogStorage('db_name')

// 打印日志
logger.log('log', '这是一条普通日志')
logger.log('warn', '这是一条警告')
logger.log('error', '这是一条错误')

const now = Date.now()
// 读取日志
logger.get({start: 0, end: now}).then(res => {
  console.log('获取到now之前的日志', res)
  logger.delete({start: 0, end: now}) // 删除日志
})

多业务场景

const imLogger = new LogStorage('db_im')
const wbLogger = new LogStorage('nim-wb')
const meetingLogger = new LogStorage('db_meeting')

imLogger.log('info', 'im业务的一条info日志')
wbLogger.log('warn', '白板业务的一条警告日志')
meetingLogger.log('error', '会议业务的一条错误日志')

const now = Date.now()
imLogger.get({start: 0, end: now}).then(res => console.log('获取IM业务日志'))
wbLogger.get({start: 0, end: now}).then(res => console.log('获取白板业务日志'))
meetingLogger.get({start: 0, end: now}).then(res => console.log('获取会议业务日志'))

注意事项

目前暂未实现数据库分表,数据量太大时查询/更新都会很慢,因此建议expire不要设置的太大,设置一个够用的最小值即可

为什么要写log-storage

  • 将日志存储在用户本地,按需收集

开发流程

目录结构

./demo    测试页代码
./src     源码
./uml     uml时序图

开发中

执行 npm run dev 打开 http://localhost:8090/demo/调试

打包

npm run build后,./dist/index.js即为目标SDK文件

打包后调试

  1. 在工程目录下起静态服务器, 假设端口是8091
  2. 访问http://localhost:8091/demo/调试