2013-04-28 11:25:37 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SharpCompress.Compressor.LZMA
|
|
|
|
|
|
{
|
|
|
|
|
|
internal static class Log
|
|
|
|
|
|
{
|
|
|
|
|
|
private static Stack<string> _indent = new Stack<string>();
|
|
|
|
|
|
private static bool _needsIndent = true;
|
|
|
|
|
|
|
|
|
|
|
|
static Log()
|
|
|
|
|
|
{
|
|
|
|
|
|
_indent.Push("");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void PushIndent(string indent = " ")
|
|
|
|
|
|
{
|
|
|
|
|
|
_indent.Push(_indent.Peek() + indent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void PopIndent()
|
|
|
|
|
|
{
|
2013-04-28 12:32:55 +01:00
|
|
|
|
if (_indent.Count == 1)
|
2013-04-28 11:25:37 +01:00
|
|
|
|
throw new InvalidOperationException();
|
|
|
|
|
|
|
|
|
|
|
|
_indent.Pop();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void EnsureIndent()
|
|
|
|
|
|
{
|
2013-04-28 12:32:55 +01:00
|
|
|
|
if (_needsIndent)
|
2013-04-28 11:25:37 +01:00
|
|
|
|
{
|
|
|
|
|
|
_needsIndent = false;
|
2013-04-28 13:01:29 +01:00
|
|
|
|
#if !PORTABLE && !NETFX_CORE
|
2013-04-28 11:25:37 +01:00
|
|
|
|
System.Diagnostics.Debug.Write(_indent.Peek());
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void Write(object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
EnsureIndent();
|
2013-04-28 13:01:29 +01:00
|
|
|
|
#if !PORTABLE && !NETFX_CORE
|
2013-04-28 11:25:37 +01:00
|
|
|
|
System.Diagnostics.Debug.Write(value);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void Write(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
EnsureIndent();
|
2013-04-28 13:01:29 +01:00
|
|
|
|
#if !PORTABLE && !NETFX_CORE
|
2013-04-28 11:25:37 +01:00
|
|
|
|
System.Diagnostics.Debug.Write(text);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void Write(string format, params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
EnsureIndent();
|
2013-04-28 13:01:29 +01:00
|
|
|
|
#if !PORTABLE && !NETFX_CORE
|
2013-04-28 11:25:37 +01:00
|
|
|
|
System.Diagnostics.Debug.Write(string.Format(format, args));
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void WriteLine()
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Diagnostics.Debug.WriteLine("");
|
|
|
|
|
|
_needsIndent = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void WriteLine(object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
EnsureIndent();
|
|
|
|
|
|
System.Diagnostics.Debug.WriteLine(value);
|
|
|
|
|
|
_needsIndent = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void WriteLine(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
EnsureIndent();
|
|
|
|
|
|
System.Diagnostics.Debug.WriteLine(text);
|
|
|
|
|
|
_needsIndent = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void WriteLine(string format, params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
EnsureIndent();
|
|
|
|
|
|
System.Diagnostics.Debug.WriteLine(string.Format(format, args));
|
|
|
|
|
|
_needsIndent = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-04-28 12:32:55 +01:00
|
|
|
|
}
|