chromium vlog 替换 log(info)

发布时间 2024-01-12 16:57:21作者: Bigben

chromium vlog log 打印输出调试

在Chromium中,DVLOG(20)是一种用于打印详细日志信息的宏。

这个宏的具体含义是在调试(Debug)版本中打印日志,而在发布(Release)版本中会被优化掉,因此在正式发布的软件中是不会产生这些日志的。

DVLOG是Debug Verbose Logging的缩写,它用于在调试模式下记录详细的日志信息。数字20表示日志的详细程度,具体的含义可能因上下文而异。通常,较低的数字表示更详细的日志。

要过滤或查看特定级别的DVLOG日志,你可以使用Chromium提供的日志过滤工具。在Chromium中,你可以使用以下命令来过滤特定级别的日志:

php
--vmodule=<module_name>=<verbosity_level>

在这里,<module_name>是你感兴趣的模块名称,可以是文件名或其他标识符,<verbosity_level>是你想要记录的详细级别。

例如,如果你想查看所有模块的DVLOG(20)日志,可以使用以下命令:

css
--vmodule=*=20

请注意,这些命令通常在运行Chromium的启动命令行中使用。你可以根据自己的需要调整过滤条件。


 

 

https://groups.google.com/a/chromium.org/g/chromium-dev/c/3NDNd1KzXeY?pli=1

 

Until recently some people have been using LOG(INFO) as "debug logging", since the default logging level was WARNING, which didn't print INFO messages.  However, there are problems with this:
  • If everyone does this, then when you set the log level to INFO to try to debug, you're deluged with messages.
  • Semantically, LOG() is supposed to be more for "messages that should always be printed", and INFO means "informative" rather than "debug" or "not printed in normal usage".
This has become a serious issue recently as we've changed the default LOG level to INFO.  Now Chrome builds are much noisier.  This is at least annoying, and in some cases worse as some users have reported slowdowns due to console log spam.
 
Instead of using LOG(INFO) for debugging, or some set of #defines that map MY_CUSTOM_LOG to various values including LOG(INFO), use VLOG.  VLOG is a recently-added facility that allows for extremely fine-grained logging control:
  • VLOG() levels can be adjusted on a per-module basis at runtime.
  • VLOG() takes an arbitrary integer value (higher numbers should be used for more verbose logging), so you can make your logging levels as granular as you wish.
Example usage:
 
./chrome --v=1 --vmodule=foo=2,bar=3
 
This runs Chrome with the global VLOG level set to "print everything at level 1 and lower", but prints levels up to 2 in foo.cc and levels up to 3 in bar.cc.
 
I have a set of changes locally, which I'll be working to check in, which globally convert LOG(INFO) to VLOG(1).  Please feel free to make drive-by comments on the code reviews if you know of code where this conversion is wrong, the VLOG level should be different than 1, the logging should just be removed, or any other non-default case.  In a few cases where people #defined their own logging facilities I have converted those and stripped the controlling macros (as VLOG's per-module control generally renders them obsolete).
 

Basically, if a
--vmodule pattern has a slash*, it will try to match the entire path
against it instead of just the module name. Note that this means
you'll almost always need to use wildcards for directory patterns,
e.g. --vmodule=*/chromeos/*=2,*chrome/browser/sync*=3.

* forward or back slash, but it must match your current platform --
I'll fix this in a future CL


chrome devtools面板适用说明,包括wasm c++调试

Chrome 调试技巧


 

vs-chromium 代码搜索

下载vs版本的代码explorer和search插件,会安装到vs2013以上版本:

http://chromium.github.io/vs-chromium/#index

下载地址:https://github.com/chromium/vs-chromium/releases/latest

启动exe文件:

cefclient.exe  -url=https://www.baidu.com  --enable-logging --v=1

加入断点即可。

vs-chromium-project.txt 

里面写入:

[SearchableFiles.include]
*

 

文档:http://chromium.github.io/vs-chromium/#getting-started