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

@xverse/log

v1.0.38

Published

XVERSE-Log

Downloads

40

Readme

SDK LOG

XVERSE-Log

日志上报

日志上报由单独的包@xverse/log 管理

使用方式如下

import { Logger, Reporter, getReportUrl } from '@xverse/log'

// 创建Logger实例,参数为模块信息
const appLog = new Logger('appLog')

// 通过getReportUrl()方法获取调度后的日志上报地址
const options = {
  appId: '11020',
  // scheduleUrl: 'https://sit-schedule.xverse.cn/sit-public/unified-schedule-service/getWSURL',
  env: 'sit',
  userId: 'test111',
  worldId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  releaseId: '2304062003_1fb32c',
  version: '2.1.31',
}
// 调度上报地址
await getReportUrl(options)
// 上报info,标准格式为 event + payload
appLog.info({ event: 'key', payload: 'value' })

// 上报warn,标准格式为 event + payload
appLog.warn({ event: 'key', payload: 'key' })

// 上报err,标准格式为 event + error
appLog.error({ event: 'key', error: 'error' })

// 测速上报,相同的 event 表示为一个测速打点
// Good Examples:
appLog.speedMarkStart('speed-event')
appLog.speedMarkEnd('speed-event')

appLog.speedMarkStart({ event: 'speed-event', ...somethingelse })
appLog.speedMarkEnd('speed-event')

appLog.speedMarkStart('speed-eventb')
appLog.speedMarkEnd({ event: 'speed-event', ...somethingelse })

// Bad Examples:
appLog.speedMarkStart('speed-event')
appLog.speedMarkEnd('speed-event')
appLog.speedMarkEnd('speed-event') // 这个点不会上报,控制台会打 warning

appLog.speedMarkStart('speed-event') // 这个 mark 点会被下面的 mark 点覆盖
appLog.speedMarkStart('speed-event')
appLog.speedMarkEnd('speed-event') // 这里的测速数据是从第二个 mark 点开始测量的

// 注意:使用 `speedMarkStart` 和 `speedMarkEnd` 进行测速上报时,可以设置 `startTime` 参数来作为测速的起点。
// 此时可以不需要先调用 `speedMarkStart` 方法。
// Example:
const startTime = Date.now()
// ... something cost a long time
appLog.speedMarkEnd({ event: 'speed-event', startTime: startTime, ...somethingelse }) // 直接上报测速点