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

@serverless-devs/logger

v0.0.5

Published

## 安装

Downloads

434

Readme

日志(@serverless-devs/logger)

安装

$ npm install @serverless-devs/logger --save

使用方式

import Logger from '@serverless-devs/logger';

/**
 * const { key1, key2, __clear, __progressFooter } = loggers;
 * 其中 key1 和 key2 是根据入参 keys 返回,使用方式如下。
 * __clear 是清理动态效果的作用,需要在退出程序之前调用
 * __progressFooter 是管理动态效果的,基于 cli-progress-footer 实现
 */
const loggers = new Logger({
  traceId: 'uuid',
  logDir: 'logFilePath',
  secrets: ['需加密字符'],
  instanceKeys: ['key1', 'key2'], // 日志实例的关键字, 传入会根据关键字生成实例。选填
});

// egg-logger
loggers.key1.info('info');
loggers.key1.warn('warn');
loggers.key1.debug('debug');
loggers.key1.error('error');
// @serverless-devs/logger 自定义的包
loggers.key1.append('append', 'INFO'); // 用于流持续输出,不受 eol 限制输出。例如:mvn命令在linux下通过文件流有换行异常可以使用此方法持续输出内容
loggers.key1.progress('update progress footer bar'); // 修改底部的动态效果文案

// 清除日志实例
loggers.unset('key1');
// loggers.key1.debug('debug'); // error: 因为

// 动态新增加密密钥
loggers.__setSecret(['key1', 'key2']);

// 新增日志实例
const logKey3 = loggers.__generate('key3');
loggers.key1.debug('debug key3');
logKey3.info('info key3');

loggers.__clear();

参数解析

import Logger from '@serverless-devs/logger';
const loggers = new Logger(options);

Options

| 参数 | 说明 | 类型 | 必填 | 默认值 | | --------- | ------------ | ----------------------------- | ---- | ------------- | | traceId | 程序运行关键字 | string | 是 | - | | logDir | 日志输出目录 | string | 是 | - | | level | 终端日志输出级别 | ALLDEBUGINFOWARNERRORNONE | 否 | 终端输出默认为:INFO;输出到文件默认为:DEBUG | | secrets | 需加密字符 | string[] | 否 | - | | eol | 自定义文件结尾 | string | 否 | os.EOL | | instanceKeys | 日志实例的关键字, 传入会根据关键字生成实例 | string[] | 否 | - |

控制输出级别

可以通过环境变量 NODE_CONSOLE_LOGGRE_LEVEL=ALLDEBUGINFOWARNERRORNONE 控制输出级别,权重大于 options.level