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 🙏

© 2025 – Pkg Stats / Ryan Hefner

si-log

v0.2.1

Published

前端日志输出解决方案

Downloads

9

Readme

log.js

前端日志工具库,简单的api,可以通过配置不同的 levelappender 来输出日志

开始使用

安装

<script src="../si_log.js" charset="utf-8"></script>

或者

npm install si-log --save

使用

siLog.debug('test debug level');
siLog.info('test info level');
siLog.warn('test warn level');
siLog.error('test error level');

CommonJs

var siLog = require('si-log')
siLog.debug('test debug level');
siLog.info('test info level');
siLog.warn('test warn level');
siLog.error('test error level');

ES6

import siLog from 'si-log'

siLog.debug('test debug level');
siLog.info('test info level');
siLog.warn('test warn level');
siLog.error('test error level');

配置输出方式

siLog.config({
  level: true
}); // output all level
siLog.config({
  level: false
}); // No output
siLog.config({
  level: ['error']
});  // only output error level
siLog.config({
  level: ['error', 'warn']
});  // only output error or warn

创建多个log对象

// render.js
var log = siLog.create('render.js')
log.debug('test in render.js output')

// [render.js]: test in render.js output

配置输出方式

siLog.config({
  appenders: {
    // console
    console: {
        printTime: true
    }
    // ...more
  }
})

自定义输出方式

siLog.appender('test', fucntion (op) {
  return function (logInfo) {
    document.write('name:' + loginfo.name);
    if (op.printTime) document.write('time:' + loginfo.timeStr);
    document.write('args:' + JSON.stringify(logInfo.args));
  }
});

siLog.config({
  appenders: {
    test: {             // use test output log
      printTime: true
    }
  }
})

API

debug([args])

相当于 console.log

info([args])

相当于 console.info

warn([args])

相当于 console.warn

error([args])

相当于 console.error

create([name])

创建新的 Log 实例

appender([name, appender])

注册一个 appender

config(options)

修改配置

License

MIT

Copyright (c) 2016 myron