Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Helper
- {
- // http://www.zeta-producer.com
- using System;
- using System.IO;
- using System.Reflection;
- /// <summary>
- /// The shortest possible logger.
- /// </summary>
- public static class QuickLogger
- {
- private static readonly Lazy<string> LogFilePath = new Lazy<string>(() =>
- {
- 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);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement