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

loghub-web

v0.7.0

Published

Lightweight logging and reporting for JavaScript

Downloads

22

Readme

loghub-web

js-standard-style

安装说明

Node.js:

npm install loghub-web

bower:

bower install loghub-web

Browser:

<script src="/pathTo/loghub-web.js"></script>

with require

var log = require('loghub-web');

with define

define(['loghub-web'], function (log) {
    //...
});

使用说明

loghub(options)

配置loghub,options是一个object,默认配置及说明如下:

options = {
  host: '',                 // 日志服务器访问地址
  token: '',                // token 验证
  slient: {                 // 禁止打印记录
    log: false,             // false为允许log方法在控制台打印记录
    error: false
  },
  report: {                 // 同步到日志服务器
    log: true,              // false为不同步
    error: true,
    globalError: true       // 是否启用 window.onerror 捕捉错误日志
  }
}

你随时可以调用loghub(options)修改配置,options将merge到原有配置, 如在生产版中禁止log打印,仅允许error:

  loghub({
    host: 'logs.teambition.net/log.gif',
    slient: {
      log: true,
      error: false
    }
  })

loghub.error(error)

默认行为同 console.error(error),处理错误日志。

loghub.log(logObj)

默认行为同 console.log(logObj),处理普通日志。

loghub.timing

页面加载性能数据,包含 fetchStart, domainLookupStart, domainLookupEnd,connectStart, connectEnd, requestStart, responseStart, responseEnd, startTime(本模块初始化时间), 可以用来衡量页面加载性能,如果浏览器不支持某个字段,其值会被设置为 0

loghub.getEntries()

资源加载性能数据,该方法返回一个数组,其中每个元素都包含 name, entryType, initiatorType, startTimeduration 字段, 可以用来衡量资源加载性能,如果浏览器不支持,则会返回一个空数组,如果特定字段不被支持, 其值会被设置为 0

loghub._errorify(error)

默认的 error 标准化方法,使用者可复写。其中 error 应该为 Error 对象实例

loghub._assembleLog(log, type)

默认的 log 标准化方法,使用者可复写。其中 log 应该对对象,type 是 'INFO''ERROR'

loghub._request(log)

默认的发送 log 到 server 的请求方法,使用者可复写。

loghub._report(log)

默认的 report 方法,使用者可复写。