namespace Helper
{
// http://www.zeta-producer.com
using System;
using System.IO;
using System.Reflection;
///
/// The shortest possible logger.
///
public static class QuickLogger
{
private static readonly Lazy LogFilePath = new Lazy(() =>
{
var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
var fileName = Path.ChangeExtension(Path.GetFileName(Assembly.GetEntryAssembly().Location), @".log");
return Path.Combine(folderPath, fileName);
});
public static void Log(string text, params object[] args)
{
if (!string.IsNullOrEmpty(text))
{
var msg = string.Format(@"[{0}, {1}\{2}] {3}" + Environment.NewLine,
DateTime.Now,
Environment.UserDomainName,
Environment.UserName,
string.Format(text, args));
File.AppendAllText(LogFilePath.Value, msg);
}
}
}
}