public static void LogEntryAsync(string message, LogSeverity logSeverity, LogCategory logCategory) { Task.Factory.StartNew(() => Logger.Write(new LogEntry { Title = logCategory.ToString(), Message = message, Categories = new List<string> { logCategory.ToString() }, Severity = GetSeverity(logSeverity) })); }
public static void LogEntry(string message, LogSeverity logSeverity, LogCategory logCategory) { Logger.Write(new LogEntry { Title = logCategory.ToString(), Message = message, Categories = new List<string> { logCategory.ToString() }, Severity = GetSeverity(logSeverity) }); }
public static void LogEntry(string message, LogSeverity logSeverity, LogCategory logCategory) { Logger.Write(new LogEntry { Title = logCategory.ToString(), Message = message, Categories = new List <string> { logCategory.ToString() }, Severity = GetSeverity(logSeverity) }); }
public static void LogEntryAsync(string message, LogSeverity logSeverity, LogCategory logCategory) { Task.Factory.StartNew(() => Logger.Write(new LogEntry { Title = logCategory.ToString(), Message = message, Categories = new List <string> { logCategory.ToString() }, Severity = GetSeverity(logSeverity) })); }
public static void AddFactory(LogCategory logCategory, INDLoggerFactory provider) { if (factorys.ContainsKey(logCategory.ToString())) { throw new ArgumentException("添加重复键值:" + logCategory.ToString()); } factorys.Add(logCategory.ToString(), provider); INDLogger logger = provider.CreateLogger(); if (logger != null) { loggerCollection.Add(logger); } }
public void Log(LogCategory category, string msg, string stackTrace) { // We use rotating log files to ensure one does not grow too big // Could also add a check for logfile size and more to be safe if (DateTime.Now >= logFileDate.AddHours(5)) { m_logFile = logFileDir + logFileDate.ToString("yyyy-dd-MMMM_hh-mm") + "_log.html"; } // If Log() is called, write a new html element to the logfile containing // the log-message, maybe a stacktrace and the log category string traceID = "trace" + traceCount; using (StreamWriter outputFile = new StreamWriter(m_logFile, true)) { string logContainer = "<p class='{category}'> <span class='time'> {time} </span> <a onClick='hide(\"{traceID}\")'> STACK </a> {msg} </p>"; logContainer = logContainer.Replace("{category}", category.ToString().ToLower()); logContainer = logContainer.Replace("{time}", DateTime.Now.ToString()); logContainer = logContainer.Replace("{traceID}", traceID); logContainer = logContainer.Replace("{msg}", msg); outputFile.WriteLine(logContainer); string stackTraceContainer = "<pre id='{traceID}'> {stackTrace} </pre>"; stackTraceContainer = stackTraceContainer.Replace("{traceID}", traceID).Replace("{stackTrace}", stackTrace); outputFile.WriteLine(stackTraceContainer); } traceCount++; }
private string FormatMessage(DateTime time, LogCategory category, LogLevel level, string message) { return(String.Format("[{0}|{1}] {2}", time, category.ToString(), message)); }
/// <summary> /// Write a new log entry with the specified category and priority. /// </summary> /// <param name="message">Message body to log.</param> /// <param name="category">Category of the entry.</param> /// <param name="priority">The priority of the entry.</param> public void Log(string message, LogCategory category, Priority priority) { string messageToLog = String.Format(CultureInfo.InvariantCulture, LoggerResources.DefaultDebugLoggerPattern, DateTime.Now, category.ToString().ToUpper(), message, priority); Debug.WriteLine(messageToLog); }
private void LogInner(LogType type, LogCategory category, string message) { #if !DEBUG if (type == LogType.Debug) { return; } #endif if (m_counter > CLEAR_TEXTBOX_THRESHOLD) { m_textBox.Clear(); m_counter = 0; } m_textBox.AppendText(category.ToString()); switch (type) { case LogType.Warning: case LogType.Error: m_textBox.AppendText(" ["); m_textBox.AppendText(type.ToString()); m_textBox.AppendText("]"); break; } m_textBox.AppendText(": "); m_textBox.AppendText(message); m_textBox.AppendText(Environment.NewLine); m_counter++; }
private IReadOnlyList <Process> LoadLogCategory(LogCategory logCategory, Directory logDirectory) { var rootDirectory = logDirectory.GetSubDirectory(logCategory.ToString()); var subDirectories = rootDirectory.GetSubDirectories(); return(subDirectories.Select(i => LoadProcess(i, logCategory)).ToList()); }
private static void LogInOtherThread(string message, LogCategory category, LogType type) { string finalMessage = ""; finalMessage += "[" + category.ToString() + "] "; finalMessage += message; SendLog(finalMessage, type); }
public static void Log(string message, LogCategory category = LogCategory.Normal) { var prefix = category != LogCategory.Normal ? category.ToString() : ""; prefix = !string.IsNullOrEmpty(prefix) ? prefix + ": " : ""; message = prefix + message; CurrentLog.Add(new Tuple <LogCategory, string>(category, message)); ToFlush.Add(message); }
public void Log(LogCategory category, string text, params object[] parameters) { if ((EnabledCategories & category) != 0) { Console.Write(LogHelpers.GetTimestamp()); ConsoleColor currentColor = Console.ForegroundColor; Console.ForegroundColor = LogHelpers.GetCategoryColor(category); Console.Write(category.ToString()); // Better to restore original than ResetColor Console.ForegroundColor = currentColor; // TODO: Check Console.BufferWidth and indent wrapping text onto the same level as the end of the timestamp // Longest LogCategory is Warning (length is 7 characters) // The log will probably mostly contain messages belonging to the // category Notice (6 chars). We want a pad of 4 spaces on average // and also want the text to be aligned with the last message // 7 + 4 = 11 is the max length of (category.ToString() + pad of 4 spaces) Console.WriteLine(new string(' ', 11 - category.ToString().Length) + text, parameters); } }
/// <summary> /// Generates log entry for selected object id (Form/Page or RequestForm/RequestPage) with some suggestion how to resolve this issue /// </summary> /// <param name="description">System.String with description</param> /// <param name="logCategory">Some categories could be suppressed by FormTransformation.exe.config file</param> /// <param name="objectId">Form or Page ID related to this log entry. If it's n/a, use LogEntryObjectId</param> /// <param name="suggestion">Add posible suggestions how to resolve this issue to log file</param> public static void GenericLogEntry(String description, LogCategory logCategory, int objectId, String suggestion) { TraceSwitch appSwitch = new TraceSwitch(logCategory.ToString(), ""); if ((generalSwitch.Level >= appSwitch.Level) || (objectId == (int)LogEntryObjectId.Error)) { string tmpDescription = description; if (objectId != (int)LogEntryObjectId.NotSpecified) { tmpDescription = String.Format(CultureInfo.InvariantCulture, Resources.Form, objectId.ToString(CultureInfo.InvariantCulture), description); } Trace.WriteLine(tmpDescription, logCategory.ToString()); Trace.Flush(); WriteToXMLLogFile(logCategory, description, objectId, suggestion); if (logCategory == LogCategory.Error) { NestingXmlDocument.ErrorInTransformation = true; } } }
public void Log(string msg, LogPriority priority, LogCategory category) { string padding = "------"; Console.WriteLine(padding); Console.WriteLine(category.ToString()); Console.WriteLine(priority.ToString()); Console.WriteLine(msg); Console.WriteLine(padding); }
public void Log(string msg, LogPriority priority, LogCategory category) { string padding = "------"; Debug.WriteLine(padding); Debug.WriteLine(category.ToString()); Debug.WriteLine(priority.ToString()); Debug.WriteLine(msg); Debug.WriteLine(padding); }
public static void WriteSimpleLog(string title, string message, LogCategory cat = LogCategory.General, int logPriority = 3) { LogWriter writer = EnterpriseLibraryContainer.Current.GetInstance <LogWriter>(); LogEntry log = new LogEntry(); log.Title = title; log.Message = message; log.Categories.Add(cat.ToString()); log.Priority = logPriority; log.Severity = System.Diagnostics.TraceEventType.Information; writer.Write(log); }
private static void LogInMainThread(string message, LogCategory category, LogType type) { if (!Config.IsEnabled(category)) { return; } string finalMessage = ""; finalMessage += "<color=#" + ColorUtility.ToHtmlStringRGB(Config.GetCategoryColor(category)) + ">"; finalMessage += "[" + category.ToString() + "]" + "</color>"; finalMessage += " " + message; SendLog(finalMessage, type); }
public static void WritePaymentLog(string title, tblInvoice invoice, tblInvoice savedOne = null, LogCategory cat = LogCategory.General, int logPriority = 3) { string message = getInvoiceMessageTemplate(invoice, savedOne); LogWriter writer = EnterpriseLibraryContainer.Current.GetInstance <LogWriter>(); LogEntry log = new LogEntry(); log.Title = title; log.Message = message; log.Categories.Add(cat.ToString()); log.Priority = logPriority; log.Severity = System.Diagnostics.TraceEventType.Information; writer.Write(log); }
/// <summary>Logs the specified level.</summary> /// <param name="level">The logging level.</param> /// <param name="category">The category.</param> /// <param name="formatMessage">The format message.</param> /// <param name="args">The parameters used when format message.</param> public static void Log(TrinityLogLevel level, LogCategory category, string formatMessage, params object[] args) { if (string.IsNullOrEmpty(prefix)) prefix = string.Format("[Trinity {0}]", Trinity.Instance.Version); if (category == LogCategory.UserInformation || level >= TrinityLogLevel.Error || (Trinity.Settings != null && Trinity.Settings.Advanced.LogCategories.HasFlag(category))) { string msg = string.Format(prefix + "{0} {1}", category != LogCategory.UserInformation ? "[" + category.ToString() + "]" : string.Empty, formatMessage); try { if (args.Length > 0) msg = string.Format(msg, args); } catch { msg = msg + " || " + args; } var key = new Tuple<LogCategory, TrinityLogLevel>(category, level); if (!LastLogMessages.ContainsKey(key)) LastLogMessages.Add(key, ""); var allowDuplicates = Trinity.Settings != null && Trinity.Settings.Advanced != null && Trinity.Settings.Advanced.AllowDuplicateMessages; string lastMessage; if (LastLogMessages.TryGetValue(key, out lastMessage) && (allowDuplicates || lastMessage != msg)) { LastLogMessages[key] = msg; switch (level) { case TrinityLogLevel.Error: _Logger.Error(msg); break; case TrinityLogLevel.Info: _Logger.Info(msg); break; case TrinityLogLevel.Verbose: _Logger.Debug(msg); break; case TrinityLogLevel.Debug: LogToTrinityDebug(msg); break; } } } }
public static void WriteExceptionLog(string title, Exception ex, LogCategory cat = LogCategory.General, int logPriority = 3, System.Diagnostics.TraceEventType severity = System.Diagnostics.TraceEventType.Error) { LogWriter writer = EnterpriseLibraryContainer.Current.GetInstance <LogWriter>(); LogEntry log = new LogEntry(); log.Title = title; if (ex != null) { log.Message = ex.Message + " Last Line: " + ex.StackTrace.Substring(ex.StackTrace.LastIndexOf(" at ")); } log.Categories.Add(cat.ToString()); log.Priority = logPriority; log.Severity = severity; writer.Write(log); }
public void LogMessage(LogCategory logCategory, string message) { switch (logCategory) { case LogCategory.Message: Console.ForegroundColor = ConsoleColor.White; break; case LogCategory.Warning: Console.ForegroundColor = ConsoleColor.Yellow; break; case LogCategory.Error: Console.ForegroundColor = ConsoleColor.Red; break; } Console.WriteLine(String.Format("{0} - {1}", logCategory.ToString(), message)); }
private void LogInner(LogType type, LogCategory category, string message) { TextRange rangeOfText = new TextRange(m_textBox.Document.ContentEnd, m_textBox.Document.ContentEnd); m_sb.Append(category.ToString()); m_sb.Append(':').Append(' '); m_sb.Append(message); m_sb.Append('\r'); m_sb.Replace("\n", string.Empty); rangeOfText.Text = m_sb.ToString(); m_sb.Clear(); if (type != m_lastLogType) { switch (type) { case LogType.Debug: rangeOfText.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Silver); rangeOfText.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Transparent); break; case LogType.Info: rangeOfText.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); rangeOfText.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Transparent); break; case LogType.Warning: rangeOfText.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Gold); rangeOfText.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Transparent); break; case LogType.Error: rangeOfText.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black); rangeOfText.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Red); break; default: throw new Exception($"Unsupported log type '{type}'"); } m_lastLogType = type; } }
public static void Log(string msg, LogCategory category, int priority, TraceEventType type, string title, IDictionary <string, object> properties, Guid?correlationId) { if (defaultWriter != null) { if (defaultWriter.IsLoggingEnabled()) { var entry = new LogEntry { Message = msg }; entry.Categories.Add(category.ToString()); entry.RelatedActivityId = correlationId; entry.Title = string.IsNullOrEmpty(title) ? Defaults.DEFAULT_LOG_TITLE : title; entry.Priority = int.MinValue == priority ? Defaults.DEFAULT_LOG_PRIORITY : priority; entry.ExtendedProperties = properties; defaultWriter.Write(entry); } else { Trace.WriteLine("Logging is disabled in the configuration."); } } else { System.Diagnostics.Trace.WriteLine("Log Manager is invalid (Null). Dumping the Log entry to trace event."); System.Diagnostics.Trace.WriteLine(string.Format("Msg: {0}\n Category: {1}\n Priority: {2} Title {3} Correlation ID: {4}", msg, category.ToString(), priority.ToString(), title, correlationId.ToString())); } }
private static void Log(string message, string application, int level, LogCategory logCategory, IList <string> tags) { ThreadPool.QueueUserWorkItem(new WaitCallback((obj) => { SnakeWebApiHttpProxy snakeWebApiHttpProxy = new SnakeWebApiHttpProxy(); snakeWebApiHttpProxy.PublishAppLog <string>(new AppLogCreatedEvent() { Guid = Guid.NewGuid().ToString(), CTime = DateTime.Now, IPv4 = UrlHelper.GetIPv4(), Application = application, AppPath = Process.GetCurrentProcess().MainModule.FileName, Machine = Environment.MachineName, LogCategory = logCategory.ToString(), Message = message, Level = level, Tags = tags }); })); }
/// <summary> /// Generates log entry for selected object id (Form/Page or RequestForm/RequestPage) with some suggestion how to resolve issue /// </summary> /// <param name="description">System.String with description</param> /// <param name="logCategory">Some categories could be suppressed by FormTransformation.exe.config file</param> /// <param name="objectId">Form or Page ID related to this log entry. If it's n/a, use LogEntryObjectId</param> /// <param name="suggestion">Add posible suggestions how to resolve this issue to log file</param> public static void GenericLogEntry(String description, LogCategory logCategory, String objectId, String suggestion) { TraceSwitch appSwitch = new TraceSwitch(logCategory.ToString(), ""); if (generalSwitch.Level >= appSwitch.Level) { try { int i = Convert.ToInt32(objectId, CultureInfo.InvariantCulture); GenericLogEntry(description, logCategory, i, suggestion); } catch (System.FormatException ex) { GenericLogEntry(ex.Message, LogCategory.IgnoreWarning, (int)LogEntryObjectId.NotSpecified, null); string tmpDescription = String.Format(CultureInfo.InvariantCulture, Resources.Form, objectId, description); GenericLogEntry(tmpDescription, logCategory, (int)LogEntryObjectId.NotSpecified, suggestion); } } }
private void DrawHeader() { GUIStyle boxStyle = new GUIStyle(GUI.skin.box); EditorGUILayout.BeginHorizontal(); GUILayoutOption heightOption = GUILayout.MinHeight(35); GUILayoutOption widthOption = GUILayout.Width((EditorGUIUtility.currentViewWidth - Padding) * 0.5f); GUILayoutOption halfWidthOption = GUILayout.Width((EditorGUIUtility.currentViewWidth - Padding) * 0.25f); GUILayout.Box(drawnCategory.ToString(), boxStyle, widthOption, heightOption); GUILayout.BeginHorizontal(widthOption); GUILayout.Box(EnabledInEditorText, boxStyle, halfWidthOption, heightOption); GUILayout.Box(EnabledInBuildText, boxStyle, halfWidthOption, heightOption); GUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); }
private void WriteLog(LogCategory category, Guid activityId, TraceEventType severity, string title, string msg, params object[] arg) { try { if (Logger.IsLoggingEnabled()) { LogEntry logEntry = new LogEntry() { ActivityId = activityId, Severity = severity, Title = title, Message = string.Format(msg, arg) }; logEntry.Categories.Add(category.ToString()); Logger.Write(logEntry); } } catch (System.Exception ex) { // ignore any exception due to logging } }
public void Log(LogCategory logCategory, string methodName, Exception exception = null, string message = null, string runGroup = null, string keyValue = null, IEnumerable <object> additionalData = null, string programName = null) { if (!IsInitialized) { return; } try { var entry = new LogEntry() { LogCategory = logCategory.ToString(), Method = methodName, ApplicationID = 193, UserID = "*****@*****.**", ComputerID = "D1NF99H2", AdditionalData = additionalData == null ? "NULL" : additionalData.ToString(), #endregion CreatedDateTime = DateTime.Now, ExceptionMessage = exception == null ? "NULL" : exception.Message, StackTrace = exception == null ? "NULL" : exception.StackTrace, RunGroupName = string.IsNullOrWhiteSpace(runGroup) ? this.RunGroupName : runGroup, Text = message, ApplicationName = ApplicationName, Environment = this.Environment, ProgramName = string.IsNullOrWhiteSpace(programName) ? this.ProgramName : programName, KeyValue = keyValue }; if (MinimumLoggingLevel >= logCategory) { Helper.InsertLog(entry); } } catch (Exception) { throw; } }
/// <summary> /// Get the Log Entry /// </summary> /// <param name="logCategory">Technocom Log Category - Log/Debug/Exception</param> /// <param name="message">Log Message</param> /// <param name="logPriority">LogPriority</param> /// <param name="eventType">TraceEventType</param> /// <returns>LogEntry</returns> private LogEntry GetLogEntry(LogCategory logCategory, string message, LogPriortiy logPriority, TraceEventType eventType) { var logEntry = new LogEntry { Message = message }; logEntry.Categories.Add(logCategory.ToString()); logEntry.Priority = (int)logPriority; logEntry.Severity = eventType; //Prepareing extended properties items var stackFrames = new StackTrace().GetFrames(); var method = stackFrames[1].GetMethod().Name; var className = stackFrames[1].GetMethod().DeclaringType.ToString(); //Add the extended properties logEntry.ExtendedProperties.Add("Class", className); logEntry.ExtendedProperties.Add("Method", method); return(logEntry); }
private void LogInner(LogType type, LogCategory category, string message) { #if !DEBUG if (type == LogType.Debug) { return; } #endif m_textBox.AppendText(category.ToString()); switch (type) { case LogType.Warning: case LogType.Error: m_textBox.AppendText(" ["); m_textBox.AppendText(type.ToString()); m_textBox.AppendText("]"); break; } m_textBox.AppendText(": "); m_textBox.AppendText(message); m_textBox.AppendText(Environment.NewLine); }
private static void WriteToXMLLogFile(LogCategory logCategory, string description, int objectID, String suggestion) { try { XmlTextWriter writer = new XmlTextWriter(sw); writer.WriteStartElement("LogEntry"); { writer.WriteElementString("LogCategory", logCategory.ToString()); writer.WriteElementString("ObjectID", objectID.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("Description", description); if (!string.IsNullOrEmpty(suggestion)) { writer.WriteElementString("Suggestion", suggestion); } } writer.WriteEndElement(); writer.Flush(); } catch (AccessViolationException ex) { GenericLogEntry(ex.Message, LogCategory.Warning, (int)LogEntryObjectId.Error); } }
public static void Log(string msg, LogCategory category, int priority, TraceEventType type, string title, IDictionary<string, object> properties, Guid? correlationId) { if (defaultWriter != null) { if (defaultWriter.IsLoggingEnabled()) { var entry = new LogEntry { Message = msg }; entry.Categories.Add(category.ToString()); entry.RelatedActivityId = correlationId; entry.Title = string.IsNullOrEmpty(title) ? Defaults.DEFAULT_LOG_TITLE : title; entry.Priority = int.MinValue == priority ? Defaults.DEFAULT_LOG_PRIORITY : priority; entry.ExtendedProperties = properties; defaultWriter.Write(entry); } else { Trace.WriteLine("Logging is disabled in the configuration."); } } else { System.Diagnostics.Trace.WriteLine("Log Manager is invalid (Null). Dumping the Log entry to trace event."); System.Diagnostics.Trace.WriteLine(string.Format("Msg: {0}\n Category: {1}\n Priority: {2} Title {3} Correlation ID: {4}", msg, category.ToString(), priority.ToString(), title, correlationId.ToString())); } }
public void WriteLog(LogCategory logCategory, string logTitle, object message, object resultMessage) { this.WriteLog(logCategory.ToString(), logTitle, message, resultMessage); }
public void Log(string message, LogCategory category, LogLevel level) { this.Log(message, category.ToString(), level); }
public void Log(string message, Exception exception, LogCategory category, LogLevel level) { this.Log(message, exception, category.ToString(), level); }
public void Log(string message, LogCategory category) { this.Log(message, category.ToString(), LevelForCategory(category)); }
public static void Write(string logModuleType, LogCategory logCategory, string logTitle, object message, object resultMessage, string messageID = "") { Write(logModuleType, logCategory.ToString(), logTitle, message, resultMessage, messageID); }