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

cyia-ngx-log

v1.2.1

Published

angular7 调试模块

Downloads

34

Readme

简介

  • 封装的一个用于输出调试的模块,目前仅限于Chrome
  • 针对log,info,warn,error可以分别开关,只要设置好生产环境和开发环境即可
  • 可以针对每个组件确定范围
  • 确定每个组件运行时间

方法

  • log/info/warn/error用法与console用法基本一致
  • setDataStyle 设置显示样式
  • start(this) 开始时使用
  • end(this) 结束时使用
  • compute(this) 计算从开始到现在到时间
  • setPrintLabel({}) 传入设置start,end,compute的输出模版,参数有{time},{name},{desc}

属性

  • flag中的Array,Object当开启时会输出为表格(当含有数组或对象时不会输出为表格)

装饰器

  • @Debugger() 对装饰方法内的console.info/log/warn/error进行重写

参数

export interface DebuggerParam {
    /**显示级别0b1111 */
    level?: number;
    /**输出样式 */
    style?: LogStyle;
    /**对象显示类型*/
    objectType?: 'table' | 'normal';
    /**数组显示类型*/
    arrayType?: 'table' | 'normal';
    /**函数显示类型*/
    functionType?: 'string' | 'object';
    /**暂时未添加功能 */
    trace?: boolean;
}

使用

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { LogModule } from "cyia-ngx-log";
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    LogModule.forRoot({ printControl: 0b1111 })
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  • 代码
  • 显示
private label: LabelTemplate = {//模版写法
    start: `[{name}-{desc}]`,
    end: `[{name}-{desc}] 结束,用时{time}秒`,
    compute: `[{name}-{desc}] 运行至此用时{time}秒`,
}

配置

export interface LogConfigure {
    printControl: number; 0b1111; //log info warn error 当这一位为1时输出开启
}

更新日志

1.2.1

  • 代码优化,升级ng7版本

1.2.0

  • 升级ng7编译
  • 增加装饰器@Debugger用于单方法的快速调试

1.1.9

  • 修复生产模式下输出

1.1.7

  • 使用angular的library方式重新生成

1.1.5

  • 修正屏蔽选项

1.1.3

  • 更新测试用例

1.1.2

  • 修正以表格输出时多出来空行的问题

1.1.1

  • 修正了一个由于依赖包更新导致编译失败的严重问题

todo

  • 对于调试的定位到行现在处理的有点low,但是好歹能定位.不知道能不能做到重写console指定,希望大牛赐教
  • 英文版...由于英文水平一般,就不献丑了,如果有大牛能帮忙翻译下,感激不禁

更多

  • 可以查看源码获得更多数据

反馈