|
using System;
namespace ONX.Cmn
{
public class Log
{
private Log()
{
}
public static void Print(string text, params object[] args)
{
DoLog("", text, args);
}
public static void Info(string text, params object[] args)
{
DoLog("INFO ", text, args);
}
public static void Warning(string text, params object[] args)
{
DoLog("WARNING ", text, args);
}
public static void Error(string text, params object[] args)
{
DoLog("!!!ERROR!!! ", text, args);
}
public static void WaitForEnter()
{
WaitForEnter("Press ENTER to continue...");
}
public static void WaitForEnter(string prompt)
{
Console.WriteLine();
Console.WriteLine();
Console.Write(prompt);
Console.ReadLine();
}
private static void DoLog(string prefix, string text, params object[] args)
{
// For newer .NET Frameworks you should use
// "System.Threading.Thread.CurrentThread.ManagedThreadId()"
// as "AppDomain.GetCurrentThreadId()" is depreceted
// there. But unfortunately it is not available in .NET v.1.1
int threadId = AppDomain.GetCurrentThreadId();
Console.Write("[{0:D4}] [{1}] ",
threadId,
DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"));
Console.Write(prefix);
Console.WriteLine(text, args);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.