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

think_logger

v2.6.0

Published

Logger for ThinkKoa.

Downloads

23

Readme

介绍


npm version Dependency Status

Logger for ThinkKoa.

安装


npm i think_logger

使用


logger(type, option, ...args)

自定义控制台输出。

  • type 控制台输出类型,例如 THINK, HTTP等

  • option { print: true, css: 'blue', record: true, path: path }

    print 是否在控制台打印日志

    css 控制台输出字符颜色,例如 white,grey,black,blue,cyan,green,magenta,red,yellow等

    record 是否保存为日志文件

    path 日志文件保存路径

  • ...args 其余可变参数。不限制参数个数。类型为数组

logger('custom', {css:'blue'}, ['测试内容']);
logger('custom', {css:'green'}, ['测试:', '测试内容']);
logger('custom', {css:'blue'}, [{"测试": "测试内容"}]);
logger('custom', {css:'blue'}, ['测试:', '测试内容']);
logger('custom', {css:'red'}, [new Error('测试内容')]);

logger.debug(...args)

自定义控制台输出debug类型信息。

  • ...args 可变参数。不限制参数个数
logger.debug('测试:', '测试内容');
logger.debug({"测试": "测试内容"});
logger.debug(['测试:', '测试内容']);
logger.debug(new Error('测试内容'));

logger.info(...args)

自定义控制台输出info类型信息。

  • ...args 可变参数。不限制参数个数
logger.info('测试:', '测试内容');
logger.info({"测试": "测试内容"});
logger.info(['测试:', '测试内容']);
logger.info(new Error('测试内容'));

logger.success(...args)

自定义控制台输出success类型信息。

  • ...args 可变参数。不限制参数个数
logger.success('测试内容');
logger.success('测试:', '测试内容');
logger.success({"测试": "测试内容"});
logger.success(['测试:', '测试内容']);
logger.success(new Error('测试内容'));

logger.warn(...args)

自定义控制台输出warn类型信息。

  • ...args 可变参数。不限制参数个数
logger.warn('测试内容');
logger.warn('测试:', '测试内容');
logger.warn({"测试": "测试内容"});
logger.warn(['测试:', '测试内容']);
logger.warn(new Error('测试内容'));

logger.error(...args)

自定义控制台输出error类型信息。

  • ...args 可变参数。不限制参数个数
logger.error('测试内容');
logger.error('测试:', '测试内容');
logger.error({"测试": "测试内容"});
logger.error(['测试:', '测试内容']);
logger.error(new Error('测试内容'));

logger.write(path, name, msgs)

自定义信息写入日志文件。自动按照日期切割。

  • path 日志保存绝对路径
  • name 日志文件名
  • msgs 接收 Error对象、字符串等类型数据

//写入日志 
await logger.write(__dirname, 'test', JSON.stringify({aa: 11}));