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

app-lib-log

v1.0.1

Published

个人日志组件 -【app-lib-log】

Downloads

124

Readme

二、功能描述

  1. 支持浏览器与 nodejs
  2. 支持彩色输出日志
  3. 支持日志级别设置
  4. 支持日志收集扩展

三、注意事项

  1. 类的方法输出 在 md 中不能呈现 在 doc/html 文档中可以

六、API

Classes

Constants

Functions

ALL_FUNCTIONS

  • 日志级别相关方法

|级别 | 堆栈 | 调试 | 日志 | 信息 | 成功 | 表格 | 时间 | 警告 | 错误| |-|-|-|-|-|-|-|-|-|-| |方法名|trace|debug|log|info|success|table|time|warn/warnNoTrace|error/errorNoTrace| |简写|t|d|l|i|s|T|tt|w/wn|e/wn| |模块化|mTrace|mDebug|mLog|mInfo|mSuccess|mTable|mTime|mWarn/mWarnNoTrace|mError/mErrorNoTrace| |简写|mt|md|ml|mi|ms|mT|mtt|mw/mwn|me/mwn|

  • 彩色转换与其他方法

参考详细文档

Kind: global constant

TYPE

日志类型

|级别 | 堆栈 | 调试 | 日志 | 信息 | 成功 | 表格 | 时间 | 警告 | 错误| |-|-|-|-|-|-|-|-|-|-| |常量名称|TRACE|DEBUG|LOG|INFO|SUCCESS|TABLE|TIME|WARN|ERROR| |常量值|trace|debug|log|info|success|table|time|warn|error|

Kind: global constant

LEVEL

日志级别

  • 通过 setOption({level:number}) 进行打印高于该值 (number) 的日志
  • 调整该顺序值进行灵活打印
  • 或者只打印某几项日志

|级别 | 堆栈 | 调试 | 日志 | 信息 | 成功 | 表格 | 时间 | 警告 | 错误| |-|-|-|-|-|-|-|-|-|-| |常量名|trace|debug|log|info|success|table|time|warn|error| |常量值|10|20|30|31|32|33|40|60|70|

Kind: global constant

option

默认配置

  • setOption - 进行设置
  • getOption - 获取当前的配置

|参数名 | 参数类型 | 参数默认值 | 参数描述 | 备注| |-|-|-|-|-| |bindGlobalName|string|log|全局的名称 | 直接在 windows 或者 nodejs 环境中直接使用 log 即可| |level|number/array|20|打印日志级别 | 低于该级别的类型忽略输出/或者打印指定级别['warn',error]的日志| |moduleName|string|''|模块名称 | 模块打印的名称|mxx 打印时直接输入自定义名称即可| |isModule|boolean|false|是否开启模块标识打印 | 关闭模块打印表示| |isColorful|boolean|true|是否开启彩色打印| |colorful|object|参考彩色配置 | 不同终端、不同级别颜色配置| |LEVEL|object|参考 LEVEL|配置打印级别值 | 灵活调整日志级别顺序| |dateFormatter|string/function|'YYYY-MM-DD HH:mm:ss'|日期打印格式化输出| |onLogger|function|null|日志输出记录 | 用于日志的收集管理|

Kind: global constant

log

  • 默认会挂载全局 直接通过 log 来使用

Kind: global constant

setOption(option) ⇒ objcet

设置配置

  • 设置后即刻生效
  • 后续日志打印按照该设置进行

Kind: global function
Returns: objcet - 新的参数配置 option

| Param | Type | Description | | --- | --- | --- | | option | object | 参考默认 option 配置 |

getOption() ⇒ object

获取配置

Kind: global function
Returns: object - 参考默认 option

auotLevel/auotLogLevel() ⇒ object

根据命令行终端参数动态设置日志级别

  • --debug
  • process.env.DEBUG 仅在 nodejs 中生效 debug 模式 默认级别为 0 否则为 21

Kind: global function
Returns: object - log 日志实例

tb/transTextColorBlock(text, opitons) ⇒ string

输出执行缩进 显示块长度 文件颜色 和背景色的 文本

  1. option 参数
  • indent 缩进
  • width 块的长度
  • algin 对齐
  • color 颜色
  • background 背景颜色

Kind: global function
Returns: string - 彩色文案

| Param | Type | | --- | --- | | text | string | | opitons | object |

tx/transTextColor(text, color, background) ⇒ string

转换文本颜色

Kind: global function
Returns: string - 彩色文案

| Param | Type | Description | | --- | --- | --- | | text | string | 文本内容 | | color | string | 文字颜色 hex 格式 | | background | string | 背景颜色 hex 格式 |

txl/transTextColorAndLog(text, color, background) ⇒ string

转换文本颜色并且打印

  • 不受级别控制

Kind: global function
Returns: string - 彩色文本内容

| Param | Type | Description | | --- | --- | --- | | text | string | 文本内容 | | color | string | 文字颜色 hex 格式 | | background | string | 背景颜色 hex 格式 |

tl/transLevelTextColor([level], text, isBackground) ⇒ string

转换指定级别文本颜色

  • 不受级别控制

Kind: global function
Returns: string - 彩色文本内容

| Param | Type | Default | Description | | --- | --- | --- | --- | | [level] | string | "TYPE.INFO" | 日志界别 参考 log.TYPE | | text | string | | 打印的文本内容 | | isBackground | boolean | | 是否包含背景 |

tll/transLevelTextColorAndLog([level], text, isBackground) ⇒ string

转换指定级别文本颜色

  • 不受级别控制

Kind: global function
Returns: string - 彩色文本内容

| Param | Type | Default | Description | | --- | --- | --- | --- | | [level] | string | "TYPE.INFO" | 日志界别 参考 log.TYPE | | text | string | | 打印的文本内容 | | isBackground | boolean | | 是否包含背景 |

tlh/transLevelHeaderAndLog(level, text, chalkOption) ⇒ string

打印指定的脚本

  • 带级别字段和内容

Kind: global function
Returns: string - 转换后的字符内容

| Param | Type | Description | | --- | --- | --- | | level | string | 级别 | | text | string | 文本内容 | | chalkOption | string | 颜色配置参数 { bg, color } 形式 |

t/trace(args) ⇒ null

trace 调试打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

d/debug(args) ⇒ null

debug 调试打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

i/info(args) ⇒ null

info 信息打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

l/log(args) ⇒ null

log 日志打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

s/success(args) ⇒ null

success 成功打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

tt/time(args) ⇒ null

time 时间打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

T/table(args) ⇒ null

table 表格打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

w/warn(args) ⇒ null

warn 警告打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

wn/warnNoTrace(args) ⇒ null

debug 调试打印

  • 不带堆栈

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

e/error(args) ⇒ null

error 错误打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

en/errorNoTrace(args) ⇒ null

error 调试打印

  • 不带堆栈

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

mt/mTrace(args) ⇒ null

mTrace 堆栈打印 (模块化)

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

md/mDebug(args) ⇒ null

mDebug 调试打印 (模块化)

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

mi/mInfo(args) ⇒ null

mInfo 信息打印 (模块化)

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

ml/mLog(args) ⇒ null

mLog 日志打印 (模块化)

  • 原生的控制台打印

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

ms/mSuccess(args) ⇒ null

mSuccess 成功打印 (模块化)

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

mtt/mTime(args) ⇒ null

mTime 调试打印 (模块化)

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

mT/mTable(args) ⇒ null

mTable 表格打印 (模块化)

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

mw/mWarn(args) ⇒ null

mWarn 告警打印 (模块化)

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

mwn/mWarnNoTrace(args) ⇒ null

mWarnNoTrace 调试打印 (模块化)

  • 不带堆栈

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

me/mError(args) ⇒ null

mError 调试打印 (模块化)

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

men/mErrorNoTrace(args) ⇒ null

mErrorNoTrace 调试打印 (模块化)

  • 不带堆栈

Kind: global function

| Param | Type | Description | | --- | --- | --- | | args | any | 打印的内容 |

autoFillText(text, length, aligin) ⇒

autoFillText 动态补全文本

  • 常用于打印类似各种级别的日志 配置配合 tl 使用

Kind: global function
Returns: 整合的字段

| Param | Type | Default | Description | | --- | --- | --- | --- | | text | string | | 文本内容 | | length | number | | 长度 默认级别打印的长度设置保持一致 超出长度按照超出的部分显示 | | aligin | string | "right" | 对齐 支持 center,left 和 默认 right |

fill(length, content) ⇒

  • 填充文本 (一般是空白)

Kind: global function
Returns: string 填充后的内容

| Param | Type | Description | | --- | --- | --- | | length | number | 填充的次数 | | content | string | 填充的内容 |

create(option) ⇒ object

  1. 第一次引入 默认创建实例
  2. 后续导入 直接返回第一次创建的实例

Kind: global function
Returns: object - logInstance 日志实例

| Param | Type | Description | | --- | --- | --- | | option | Object | 详细参数参考 option |