GithubHelp home page GithubHelp logo

mini-peanut / console-with-explain Goto Github PK

View Code? Open in Web Editor NEW
18.0 0.0 1.0 55 KB

用于调试框架源码:输出console时自动带上该console所在方法名,文件名,和行数

JavaScript 100.00%
console

console-with-explain's Introduction

console-with-explain

用于调试框架源码:输出console时自动带上该console所在方法名,文件名,和行数

使用

npm install console-with-explain

main.js 全局替换console

// 浏览器环境
if (process.env.NODE_ENV === 'development') {
    const createConsole = require('console-with-explain')
    window.console = createConsole({preClear: true})
}

其他文件 直接使用console

// ...otherCode
mounted() {
  console.log('here');
}
// ...other code

效果图

image

配置参数


preClear {Boolean} 默认false, 打印之前是否清除之前的控制台输出
enableGroup {Boolean} 默认true, 是否使用group分组
pathDepth {Number} 默认2, 打印路径的深度

性能

同一位置,只计算一次,之后使用缓存,不存在性能问题

todolist

  • 支持打印async await方法名

Q && A

Q:已经有sourcemap了,为什么要用这个

A: sourcemap 需要点进去才能看到该代码里相应的位置, 在控制台上查看多个console时并不直观,本插件就是你使用console时,自动为你打印你输出的位置,包括方法名,文件路径,行数,可以更加直观的分析打印出来的数据

console-with-explain's People

Contributors

mini-peanut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

bulesky123

console-with-explain's Issues

老哥不支持node环境哈

老哥测试了下不支持Node 环境的使用哈。而且文档里面 process.env.NODE_ENV === 'development' 很容易误解支持node。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.