📄 log.cs
字号:
using System;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using ShootSearch.Helper;
namespace ShootSearch.Logging
{
/// <summary>
/// Log 的摘要说明。
/// </summary>
public class Log
{
public Log()
{
}
public static string EchoPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + "/log.txt";
public static string DebugPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + "/debug.txt";
public static bool EchoEnabled = false;
public static bool DebugEnabled = true;
public static ConsoleOut m_Console;
#region Init()
public static void Init(ConsoleOut p_Console)
{
m_Console = p_Console;
}
#endregion
#region Echo()
[MethodImpl(MethodImplOptions.Synchronized)]
public static void Echo(object obj)
{
if (obj == null || m_Console == null)
return;
string msg = obj.ToString();
if (EchoPath == null)
return;
if (!EchoEnabled)
return;
m_Console.WriteLine(DateTime.Now + " " + msg);
Console.WriteLine(DateTime.Now + " " + msg);
if(Config.ConsoleFileOut)
{
using (StreamWriter sw = new StreamWriter(EchoPath, true))
{
sw.WriteLine(DateTime.Now + " " + msg);
sw.Close();
}
}
}
#endregion
#region Debug()
[MethodImpl(MethodImplOptions.Synchronized)]
public static void Debug(object obj)
{
if (obj == null)
return;
string msg = obj.ToString();
if (DebugPath == null)
return;
if (!DebugEnabled)
return;
if(Config.ConsoleFileOut)
{
using (StreamWriter sw = new StreamWriter(DebugPath, true))
{
sw.WriteLine(DateTime.Now + " " + msg);
sw.Close();
}
}
}
#endregion
#region ProcessURL() 输出处理的URL
/// <summary>
/// 输出处理的URL
/// </summary>
/// <param name="obj"></param>
[MethodImpl(MethodImplOptions.Synchronized)]
public static void ProcessURL(object obj)
{
if (obj == null || m_Console == null)
return;
string msg = obj.ToString();
if ( Config.ConsoleProcessURL )
{
m_Console.WriteLine(msg) ;
}
Console.WriteLine(DateTime.Now + " " + msg);
}
#endregion
#region ResultURL 输出URL处理结果
/// <summary>
/// 输出URL处理结果
/// </summary>
/// <param name="obj"></param>
[MethodImpl(MethodImplOptions.Synchronized)]
public static void ResultURL(object obj)
{
if (obj == null || m_Console == null)
return;
string msg = obj.ToString();
if ( Config.ConsoleResultURL )
{
m_Console.WriteLine(msg) ;
}
Console.WriteLine(DateTime.Now + " " + msg);
}
#endregion
#region Echo()
public static void SetURLCount(int p_Remain)
{
// if(m_Console != null)
// m_Console.
}
#endregion
#region Echo()
public static void SetProcessedCount(string str)
{
}
#endregion
#region Echo()
public static void SetElapsedTime(string str)
{
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -