如何让 SysInternals DebugView 显示缩进?

发布于 2024-12-08 16:09:34 字数 1328 浏览 0 评论 0原文

我正在将 SysInternals DebugView 与我的 .Net 应用程序一起使用。我尝试过使用 .Net Debug 类的缩进功能,但 DebugView 似乎只是将其表示为 NewLine 字符。

有谁知道是否可以让 DebugView 显示缩进?

示例代码:

static void Main (string[] args)
{
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);

    Debug.Indent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
    Debug.Indent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
    Debug.Indent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);

    Debug.Unindent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
    Debug.Unindent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
    Debug.Unindent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
}

输出:

[9632] Indent level: 0
[9632]
[9632] Indent level: 1
[9632]
[9632]
[9632] Indent level: 2
[9632]
[9632]
[9632]
[9632] Indent level: 3
[9632]
[9632]
[9632] Indent level: 2
[9632]
[9632] Indent level: 1
[9632] Indent level: 0

我想看到的内容:

[9632] Indent level: 0
[9632]   Indent level: 1
[9632]     Indent level: 2
[9632]       Indent level: 3
[9632]     Indent level: 2
[9632]   Indent level: 1
[9632] Indent level: 0

Rik

I'm using SysInternals DebugView with my .Net application. I've tried using the Indent feature of the .Net Debug class, but DebugView just seems to represent this as a NewLine character.

Does anyone know if it's possible to get DebugView to display the indents?

Sample Code:

static void Main (string[] args)
{
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);

    Debug.Indent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
    Debug.Indent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
    Debug.Indent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);

    Debug.Unindent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
    Debug.Unindent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
    Debug.Unindent();
    Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
}

Output:

[9632] Indent level: 0
[9632]
[9632] Indent level: 1
[9632]
[9632]
[9632] Indent level: 2
[9632]
[9632]
[9632]
[9632] Indent level: 3
[9632]
[9632]
[9632] Indent level: 2
[9632]
[9632] Indent level: 1
[9632] Indent level: 0

What I'd Like to see:

[9632] Indent level: 0
[9632]   Indent level: 1
[9632]     Indent level: 2
[9632]       Indent level: 3
[9632]     Indent level: 2
[9632]   Indent level: 1
[9632] Indent level: 0

Rik

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

滴情不沾 2024-12-15 16:09:34

但是等等!看起来是有可能的。您只需在选项菜单上关闭强制回车功能即可。

我在这里找到了答案:
http://forum.sysinternals.com/topic26797_post131196.html#131196

这是文本:

默认情况下,强制回车选项处于启用状态,该选项显示传递的每个字符串
到单独行上的调试输出函数,无论该文本是否以
回车。如果在“选项”菜单中禁用该选项,则 DebugView 会缓冲输出
仅当遇到回车符或
内存缓冲区已满(大约 4192 个字符)。这允许应用程序和驱动程序
通过多次调用调试输出函数来构建输出行。

But wait! It looks like it is possible. You just need to turn off the Force Carriage Returns feature on the Options menu.

I discovered the answer here:
http://forum.sysinternals.com/topic26797_post131196.html#131196

Here's the text:

By default, the Force Carriage Returns option is enabled, which displays every string passed
to a debug output function on a separate line, whether or not that text is terminated with a
carriage return. If you disable that option in the Options menu, DebugView buffers output
text in memory and adds it to the display only when a carriage return is encountered or the
memory buffer is filled (approximately 4192 characters). This allows applications and drivers
to build output lines with multiple invocations of debug output functions.

多情癖 2024-12-15 16:09:34

我认为你不能让 DebugView 这样做。它捕获单独的输出写入,因此当您执行 Debug.WriteLine 时,调试类将缩进空间单独输出为单独的 OutputDebugString 调用。您仍然可以做的就是自己添加缩进空间,并将您的写入映射到单个底层 API 调用中:

string currentIndent = "  ";
// ...
Debug.WriteLine(currentIndent + "Indent level: {0}", Debug.IndentLevel);

I don't think you can make DebugView do this way. It captures individual output writes, so it seems that when you do Debug.WriteLine Debug class outputs indentation space individually as separate OutputDebugString calls. What you definitely still can do is adding indentation space yourself and have your writes mapped into single underlying API calls:

string currentIndent = "  ";
// ...
Debug.WriteLine(currentIndent + "Indent level: {0}", Debug.IndentLevel);
笔芯 2024-12-15 16:09:34
Debug.IndentLevel = 0; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 1; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 2; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 3; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 3; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 2; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 1; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 0; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);


Indent level: 0
    Indent level: 1
        Indent level: 2
            Indent level: 3
            Indent level: 3
        Indent level: 2
    Indent level: 1
Indent level: 0
Debug.IndentLevel = 0; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 1; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 2; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 3; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 3; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 2; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 1; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);
Debug.IndentLevel = 0; Debug.WriteLine("Indent level: {0}", Debug.IndentLevel);


Indent level: 0
    Indent level: 1
        Indent level: 2
            Indent level: 3
            Indent level: 3
        Indent level: 2
    Indent level: 1
Indent level: 0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文