public void TraceData(TraceEventType type, int eventId, string data) { _hasError = _hasError || type.Equals(TraceEventType.Error) || type.Equals(TraceEventType.Critical); _traceInfos.Add(new TraceInfo() { Type = type, EventId = eventId, Format = "{0}", Args = new object[] { data } }); }
public void TraceEvent(TraceEventType type, int eventId, string format, params object[] args) { _hasError = _hasError || type.Equals(TraceEventType.Error) || type.Equals(TraceEventType.Critical); _traceInfos.Add(new TraceInfo() { Type = type, EventId = eventId, Format = format, Args = args }); }
private void LogMessage(string message, TraceEventType eventType) { if (eventType.Equals(TraceEventType.Critical) || eventType.Equals(TraceEventType.Error)) { UnityEngine.Debug.LogError(message); } else if (eventType.Equals(TraceEventType.Warning)) { UnityEngine.Debug.LogWarning(message); } else { UnityEngine.Debug.Log(message); } }
private void LogMessage(string message, TraceEventType eventType) { if (eventType.Equals(TraceEventType.Critical) || eventType.Equals(TraceEventType.Error)) { Debug.LogError((object)message); } else if (eventType.Equals(TraceEventType.Warning)) { Debug.LogWarning((object)message); } else { Debug.Log((object)message); } }
/// <summary> /// Writes trace information, a message and event information to the output file or stream. /// </summary> /// <param name="eventCache">A <see cref="T:System.Diagnostics.TraceEventCache" /> object that contains the current process ID, thread ID, and stack trace information.</param> /// <param name="source">A name of the trace source that invoked this method.</param> /// <param name="eventType">One of the <see cref="T:System.Diagnostics.TraceEventType" /> enumeration values.</param> /// <param name="id">A numeric identifier for the event.</param> /// <param name="message">A message to write.</param> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" /> /// </PermissionSet> public override void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message) { if (!eventType.Equals(TraceEventType.Critical)) { char eventTypeChar = 'E'; switch (eventType) { case TraceEventType.Information: eventTypeChar = 'I'; break; case TraceEventType.Warning: eventTypeChar = 'W'; break; case TraceEventType.Error: eventTypeChar = 'E'; break; case TraceEventType.Critical: eventTypeChar = 'C'; break; } string header = String.Format("{0},{1},{2},", eventCache.DateTime.ToLocalTime().ToString("MM/dd/yy,HH:mm:ss.ffff"), id, eventTypeChar); // Prepend timestamp to messages with multiple lines so that addition lines in message // lines up to first line after the timestamp if (message.Contains(Environment.NewLine)) { message = message.Replace(Environment.NewLine, Environment.NewLine + header); } BaseFileName = OriginalFileName + "_H" + DateTime.Now.Hour; base.WriteLine(header + message); PurgeLogFiles(MaxLogFilesAllowed, eventCache); // purge older log files if got to many } else { // Maintenance log file header.. string _date = DateTime.Now.ToString("-yyyy-MM-dd"); string LogFilePathForMaintenance = string.Format("{0}\\{1}_Maintenance{2}.log", CustomLocation, OriginalFileName, _date); if (!File.Exists(LogFilePathForMaintenance)) { // File.Create(LogFilePathForMaintenance).Dispose(); using (StreamWriter w = File.AppendText(LogFilePathForMaintenance)) { w.WriteLine("Time Stamp, Error Code, Error Category, Error Message, Type"); w.Close(); } } BaseFileName = OriginalFileName + "_Maintenance"; string header = String.Format("{0},", eventCache.DateTime.ToLocalTime().ToString("MM/dd/yy - HH:mm:ss")); // Prepend timestamp to messages with multiple lines so that addition lines in message // lines up to first line after the timestamp if (message.Contains(Environment.NewLine)) { message = message.Replace(Environment.NewLine, Environment.NewLine + header); } //Force to be not over 5 comma index var msgsplit = message.Split(','); if (msgsplit.Length > 4) { message = string.Empty; message = string.Format("{0},{1},{2},{3}", msgsplit[0], msgsplit[1], msgsplit[2], msgsplit[3]); } base.WriteLine(header + message); } }
private void CutOffEnsurer(TraceEventType eventType, int id, string message) { _cutOff = eventType.Equals(TraceEventType.Information) && id.Equals(0) && !string.IsNullOrEmpty(message) && message.Equals(Resources.RollingXmlWriterTraceListener_CutOff); }