关于用log提高排查问题的设置

今天在了解项目业务的时候,想搞清楚执行顺序,加了很多打印,类似console.log(1111,xxxx) console.log(2222,xxxx),有时候断点没开sourcemap不是源码所以我更喜欢打印,然后就导致打印比较紊乱,而且前面的1111 2222标识多了就不够清晰,就写了 一个这个配置很方便,输入log直接出现文件名和第多少行
在这里插入图片描述

具体配置如下:
打开 VSCode。
按 Ctrl+Shift+P(Windows/Linux)或 Cmd+Shift+P(macOS)打开命令面板。
输入 Preferences: Configure User Snippets
选择对应文件代码片段 我选的是全局

{  
        // Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and  
        // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:  
        // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the  
        // same ids are connected.  
        // Example:  
        "Print to console": {  
                "prefix": ["console.log", "console", "log"],  
                "body": [  
                        "console.log('log输出--:[$TM_FILENAME:$TM_LINE_NUMBER]行:', $1);"  
                ],  
                "description": "Log output to console"  
        }  
}

输入一下格式 保存即可,body里面可以自定义。

也有同事推荐了urbo Console Log 这个拓展,小火箭打印,但是我觉得扩展插件的注入应该增加了体积,我就自己写了一个,大家可以按需使用。

EDN

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值