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

ngx-logger-icy

v2.0.0

Published

angular9+以上的版本可以使用;继承console上的方法,可以根据环境变量控制log是否输出,解决开发环境需要打印一些log日志但是生产环境并不需要

Downloads

1

Readme

ngx-logger-icy

angular4+以上的版本可以使用;继承console上的方法,可以根据环境变量控制log是否输出,解决开发环境需要打印一些log日志但是生产环境并不需要;demo地址

1、开始使用

  • 安装
  • 使用

2、LoggerService中的方法

  • log()
  • info()
  • debug()
  • error()
  • warn()
  • assert()
  • clear()
  • count()
  • group()
  • groupCollapsed()
  • groupEnd()
  • table()
  • time()
  • timeEnd()
  • trace()
  • profile()

安装

npm i ngx-logger-icy

使用

LoggerModule应该在AppModule中使用forRoot()静态方法注册,在子模块中使用forChild()注册。这些方法也接受enable对象。将其保留为默认值为空是true

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

import { LoggerModule } from 'ngx-logger-icy';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    LoggerModule.forRoot(environment.enableConsole),// forRoot()如果为空,默认值为true
    AppRoutingModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
import { Component } from '@angular/core';
import { LoggerService } from 'ngx-logger-icy';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.less']
})
export class AppComponent {
  constructor(
    private _logger: LoggerService
  ) {
    this._logger.log('%c这就输出了。', 'color: green');
    this._logger.debug();
    this._logger.error('我是错误的输出。');
  }
}

log()

/**
 * 输出信息
 * @description 同console.log()
 */
log(): Function;

info()

/**
 * log别名,输出信息
 * @description 同console.info()
 */
info(): Function;

debug()

/**
 * @description 同console.debug()
 */
debug(): Function;

error()

/**
 * 输出信息时,在最前面加一个红色的叉,表示出错,同时会显示错误发生的堆栈。
 * @description 同console.error()
 */
error(): Function;

warn()

/**
 * 输出警告信息
 * @description 同console.warn()
 */
warn(): Function;

assert()

/**
 * @param boolean
 * @param string
 * @description 同console.assert(); 接受两个参数,只有当第一个参数为false,才会输出第二个参数,否则不输出任何东西
 */
assert(): Function;

clear()

/**
 * 清除当前控制台的所有输出,将光标回置到第一行
 * @description 同console.clear();此方法不分环境
 */
clear(): Function;

count()

/**
 * 用于计数,输出它被调用了多少次。
 * @description 同console.count()
 */
count(): Function;

group()

/**
 * 用于将显示的信息分组,可以把信息进行折叠和展开。
 * @description 同console.group()
 */
group(): Function;

groupCollapsed()

/**
 * 与group方法很类似,唯一的区别是该组的内容,在第一次显示时是收起的(collapsed),而不是展开的
 * @description 同console.groupCollapsed()
 */
groupCollapsed(): Function;

groupEnd()

/**
 * 结束内联分组
 * @description 同console.groupEnd()
 */
groupEnd(): Function;

table()

/**
 * 将复合类型的数据转为表格显示
 * @description 同console.table()
 */
table(): Function;

time()

/**
 * 计时开始
 * @description 同console.time()
 */
time(): Function;

timeEnd()

/**
 * 计时结束
 * @description 同console.timeEnd()
 */
timeEnd(): Function;

trace()

/**
 * 追踪函数的调用过程
 * @description 同console.trace()
 */
trace(): Function;

profile()

/**
 * 性能分析器
 * @description 同console.profile()
 */
profile(): Function;