简介
- 封装的一个用于输出调试的模块,目前仅限于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 {
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;
}
更新日志
1.2.1
1.2.0
- 升级ng7编译
- 增加装饰器
@Debugger
用于单方法的快速调试
1.1.9
1.1.7
1.1.5
1.1.3
1.1.2
1.1.1
todo
- 对于调试的定位到行现在处理的有点low,但是好歹能定位.不知道能不能做到重写console指定,希望大牛赐教
- 英文版...由于英文水平一般,就不献丑了,如果有大牛能帮忙翻译下,感激不禁
更多
反馈
- 邮箱wszgrcy@gmail.com,如果有问题,bug或建议请发送到这里来