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

taoye-logger

v1.1.10

Published

a simple logger for better life

Downloads

12

Readme

前端通用日志管理器


platform-logger 是前端日志管理的工具,提供了简洁有效的API供替代前端“最爱”的 console

通用日志管理器为前端日志的格式化输出和统计监控提供了非常实用的支持。

通用日志管理器发布在之家私有npm仓库:http://npm.corpautohome.com/
执行npm install 前需要先设置一下 npm config_backup set @auto:registry http://r.npm.corpautohome.com/

使用说明

$ npm install @auto/platform-logger --save

import {Logger, ttyConsole, ttyMonitor} from '@auto/platform-logger';

// 设置全局日志输出器的命名空间,一般为具体平台的名称,缺省值为'platform'
// 日志格式为 `LEVEL [namespace](loggerName) - logInfo`
Logger.setNamespace('xxx-plat');

// 设置全局日志管理器的日志输出级别(大小写均可),缺省为DEBUG,即全部输出
// 可选项及级别优先级  DEBUG < LOG < INFO < WARN < ERROR
Logger.setLevel('LOG');

// 设置日志接收终端的日志过滤级别
// 注意,如果级别低于 全局日志管理器的级别,则不会收到相关级别的日志
ttyConsole.setLevel('DEBUG');
ttyMonitor.setLevel('WARN');

// 设置监控终端的服务器上报地址,缺省为 http://console.autohome.com.cn/monit?
ttyMonitor.setURL('http://example.com/monit?');

// 设置日志输出终端,缺省只输出到ttyConsole
Logger.use(ttyConsole).use(ttyMonitor);
// 也可以在业务代码中按需自定义输出终端
Logger.use({
    output: (LEVEL, namespace, loggerName, ...logInfo) => {
        // 处理逻辑
    }
});

/* 具体业务模块调用示例 */
// 获取一个日志实例,并设置loggername
const logger = Logger.get('demo');

logger.debug('code debug info');
logger.log('business log info');
logger.info('business key log info');
logger.warn('business warn info');
logger.error('code or business error info', 'extinfo', ...);

日志输出终端效果展示

ttyConsole

avatar

ttyConsole with logHelper

avatar