public LogEventInfo(LogLevel level, string logger, string message, Exception ex) { Level = level; Logger = logger; Message = message; Exception = ex; TimeStamp = LogManagerBase.GetDateTime(); SequenceID = GetNextSequenceId(); }
public void TestTimestampBoth() { var naming = new FileNamingParameters() { IncludeLevel = false, IncludeLogger = false, IncludeSequence = false, IncludeSession = false, IncludeTimestamp = FileTimestampMode.DateTime }; // ok... var info = GetLogEventInfo(); // check... var filename = naming.GetFilename(new LogWriteContext(), info); Assert.Equal(string.Format("Log - {0}.log", LogManagerBase.GetDateTime().ToString("yyyyMMdd HHmmss")), filename); }
public void TestEverythingOn() { var naming = new FileNamingParameters() { IncludeLevel = true, IncludeLogger = true, IncludeSequence = true, IncludeSession = true, IncludeTimestamp = FileTimestampMode.DateTime }; // ok... var info = GetLogEventInfo(); // check... var context = new LogWriteContext(); var filename = naming.GetFilename(context, info); Assert.Equal(string.Format("Log - INFO - foobar - {0} - {1} - {2}.log", LogManagerBase.GetDateTime().ToString("yyyyMMdd HHmmss"), context.Environment.SessionId, info.SequenceID), filename); }
public void Log(LogLevel logLevel, string message, Exception ex) { string formatted = null; long sequence = LogEventInfo.GetNextSequenceId(); string dt = LogManagerBase.GetDateTime().ToString(LogManagerBase.DateTimeFormat); string asString = logLevel.ToString().ToUpper(); int thread = Environment.CurrentManagedThreadId; if (ex != null) { formatted = string.Format("{0}|{1}|{2}|{3}|{4} --> {5}", sequence, dt, asString, thread, message, ex); } else { formatted = string.Format("{0}|{1}|{2}|{3}|{4}", sequence, dt, asString, thread, message); } // debug... System.Diagnostics.Debug.WriteLine(formatted); // TODO: EWT }