Created
February 16, 2015 09:00
-
-
Save brunnurs/e8400a992eb3a6ef5a77 to your computer and use it in GitHub Desktop.
iOS FileLogger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Drallo.Mobile.Lib.Helper; | |
using System.IO; | |
using System.Diagnostics; | |
namespace Drallo.Mobile.LibrarySpecializations.Logging | |
{ | |
public class TouchFileLogger : ILogger | |
{ | |
static object locker = new object(); | |
private string logfilePath; | |
public TouchFileLogger() | |
{ | |
string timeString = DateTime.Now.ToString("yy_MM_dd__hh_mm_ss"); | |
logfilePath = String.Format("{0}/appNameLog_{1}.txt",Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),timeString); | |
} | |
#region ILogger implementation | |
public void Write(LogLevel level, string tag, string message) | |
{ | |
string timeString = DateTime.Now.ToString("G"); | |
lock (locker) | |
{ | |
using (StreamWriter w = File.AppendText(logfilePath)) | |
{ | |
w.WriteLine(timeString + " " + level + " " + message); | |
} | |
} | |
} | |
#endregion | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment