public static AssetLogMessage From(Package package, IReference assetReference, ILogMessage logMessage, string assetPath, int line = 0, int character = 0) { // Transform to AssetLogMessage var assetLogMessage = logMessage as AssetLogMessage; if (assetLogMessage == null) { assetLogMessage = new AssetLogMessage(null, assetReference, logMessage.Type, AssetMessageCode.CompilationMessage, assetReference?.Location, logMessage.Text) { Exception = (logMessage as LogMessage)?.Exception }; } // Set file (and location if available) assetLogMessage.File = assetPath; assetLogMessage.Line = line; assetLogMessage.Character = character; // Generate location (if it's a Yaml exception) var yamlException = (logMessage as LogMessage)?.Exception as YamlException; if (yamlException != null) { assetLogMessage.Line = yamlException.Start.Line; assetLogMessage.Character = yamlException.Start.Column; // We've already got everything, no need to pollute log with stack trace of exception assetLogMessage.Exception = null; } return assetLogMessage; }
protected override void OnLog(ILogMessage logMessage) { // Always log when debugger is attached if (logMessage.Type < LogLevel) { return; } var color = ConsoleColor.Gray; // set the color depending on the message log level switch (logMessage.Type) { case LogMessageType.Debug: color = ConsoleColor.DarkGray; break; case LogMessageType.Verbose: color = ConsoleColor.Gray; break; case LogMessageType.Info: color = ConsoleColor.Green; break; case LogMessageType.Warning: color = ConsoleColor.Yellow; break; case LogMessageType.Error: case LogMessageType.Fatal: color = ConsoleColor.Red; break; } logger(GetDefaultText(logMessage), color); }
/// <inheriteddoc /> protected sealed override void OnLog(ILogMessage msg, ref bool success) { lock (SyncRoot) { base.OnLog(msg, ref success); } }
private void OnMessageLogged(ILogMessage msg) { if (this.MessageLogged != null) { this.MessageLogged(msg); } }
protected override void ExportLogMessage(IRepositoryContext context, ISession session, ILogMessage message) { WriteLine(); if (message.Severity == LogMessageSeverity.Verbose) Write("{0} {1}\r\n", message.Timestamp, message.Caption.Trim()); else { var severity = message.Severity.ToString(); if (severity.StartsWith("Info") || severity.StartsWith("Warn")) severity = severity.Substring(0, 4); else severity = severity.ToUpperInvariant(); Write("{0} {2} {1}\r\n", message.Timestamp, message.Caption.Trim(), severity); } if (string.IsNullOrEmpty(message.Description) == false) { Write("{0}\r\n", message.Description.Trim()); } Write("Category: {0} from {1}", message.CategoryName, message.LogSystem); if (string.IsNullOrEmpty(message.ClassName) == false) { Write(" {0}.{1}", message.ClassName, message.MethodName); } if (string.IsNullOrEmpty(message.FileName) == false) { Write(" in {0} ({1})", message.FileName, message.LineNumber); } WriteLine(); Write("Thread: {0} ({1}) for {2}\r\n", message.ThreadName, message.ThreadId, message.UserName); IExceptionInfo currentException = message.Exception; if (currentException != null) { if (Config.IncludeExceptionDetails) { var label = "EXCEPTION"; while (currentException != null) { Write("{0}: {1} - {2} from {3}\r\nStack Trace:\r\n{4}\r\n", label, currentException.TypeName, currentException.Message.Trim(), currentException.Source, currentException.StackTrace); currentException = currentException.InnerException; label = "INNER EXCEPTION"; } } else { while (currentException != null) { Write("{0}: {1}\r\n", currentException.TypeName, currentException.Message.Trim()); currentException = currentException.InnerException; } } WriteLine(); } }
protected override void LogRaw(ILogMessage logMessage) { buildStep.Logger.Log(logMessage); mainLogger?.Log(logMessage); StepLogger?.Log(logMessage); }
/// <inheriteddoc /> protected override void OnLog(ILogMessage msg, ref bool success) { var sb = new StringBuilder(); CreateString(msg, sb); Debug.WriteLine(sb.ToString()); }
protected override void OnLog(ILogMessage message) { var serializableMessage = message as SerializableLogMessage; if (serializableMessage == null) { var assetMessage = message as AssetLogMessage; if (assetMessage != null) { assetMessage.Module = mainLogger.Module; serializableMessage = new AssetSerializableLogMessage(assetMessage); } else { var logMessage = message as LogMessage; serializableMessage = logMessage != null ? new SerializableLogMessage(logMessage) : null; } } if (serializableMessage == null) { throw new ArgumentException(@"Unable to process the given log message.", "message"); } foreach (var remoteLog in remoteLogs) { try { remoteLog.ForwardSerializableLog(serializableMessage); } // ReSharper disable EmptyGeneralCatchClause catch { } // ReSharper restore EmptyGeneralCatchClause } }
private void Log(ILogMessage obj) { if (MessageLogged != null) { MessageLogged(obj); } }
public CLogMessage( IMessageSerializer messageSerializer, DateTime timeStamp, LogMessageCategoryEnum messageCategory, bool isException, bool isRootMessage, string source, string message, string messageStackTrace, string exceptionStackTrace, ILogMessage childMessage ) { if (messageSerializer == null) { throw new ArgumentNullException("messageSerializer"); } //childMessage allowed to be null _messageSerializer = messageSerializer; _timeStamp = timeStamp; _messageCategory = messageCategory; _isException = isException; _isRootMessage = isRootMessage; _source = source; _message = message.CrLnNormalize(); _messageStackTrace = messageStackTrace.CrLnNormalize(); _exceptionStackTrace = exceptionStackTrace.CrLnNormalize(); _childMessage = childMessage; }
protected override void LogRaw(ILogMessage logMessage) { TimeSpan timestamp = DateTime.Now - startTime; lock (Messages) { Messages.Add(new Message(timestamp.Ticks, logMessage)); } }
public void Add(ILogMessage item) { lock(syncObj) //We can just lock because we don't lock anymore while taking. Deadlocks used to occur before, and the fix didn't work 100%, so we now don't lock on Take(). //We were able to do it lockless because we caught dipose and cancel exceptions and continued on them. There is little to no contention on syncObj anymore. { messageCollection.Add(item); } }
protected override void OnLog(ILogMessage logMessage) { Debug.WriteLine(GetDefaultText(logMessage)); var exceptionMsg = GetExceptionText(logMessage); if (!string.IsNullOrEmpty(exceptionMsg)) { Debug.WriteLine(exceptionMsg); } }
protected override void OnLog(ILogMessage message) { if (!activeRemoteLogs) return; var serializableMessage = message as SerializableLogMessage; if (serializableMessage == null) { var assetMessage = message as AssetLogMessage; if (assetMessage != null) { assetMessage.Module = mainLogger.Module; serializableMessage = new AssetSerializableLogMessage(assetMessage); } else { var logMessage = message as LogMessage; serializableMessage = logMessage != null ? new SerializableLogMessage(logMessage) : null; } } if (serializableMessage == null) { throw new ArgumentException(@"Unable to process the given log message.", "message"); } for (int i = 0; i < remoteLogs.Count; i++) { var remoteLog = remoteLogs[i]; try { remoteLog?.ForwardSerializableLog(serializableMessage); } // ReSharper disable EmptyGeneralCatchClause catch { // Communication failed, let's null it out so that we don't try again remoteLogs[i] = null; TryCloseChannel(remoteLog); // Check if we still need to log anything var newActiveRemoteLogs = false; for (int j = 0; j < remoteLogs.Count; j++) { if (remoteLogs[j] != null) { newActiveRemoteLogs = true; break; } } activeRemoteLogs = newActiveRemoteLogs; } // ReSharper restore EmptyGeneralCatchClause } }
}// end constructeur /// <summary> /// Enregistre Le message dans un fichier de Log /// </summary> /// <param name="MonLevel">Niveau de criticité</param> /// <param name="MonMessage">Message à enresgitrer</param> /// <param name="MonContexte">Contexte d'exécution</param> public override void SendMessage(LogLevel MonLevel, ILogMessage MonMessage, ILogContexte MonContexte) { DBCnx curCon = DbCnxManager.CreateConnectionFromConnectingString(ConnectionString); curCon.SQL_Execute("PR_LOG_MESSAGE", "@LOG_LEVEL", MonLevel, "@Origin", MonContexte.Origin, "@scope", MonContexte.Scope, "@loguser", MonContexte.CurrentUser , "@domaine", MonMessage.Domaine, "@MESSAGE_NUMBER", MonMessage.NumMessage, "@LOG_MESSAGE", MonMessage.TexteMessage, "@OTHERSINFOS", JsonConvert.SerializeObject(MonContexte.InfosComplementaires)); curCon.Dispose(); }
protected override void LogRaw(ILogMessage logMessage) { base.LogRaw(logMessage); if (loggerToForward != null) { lock (loggerToForward) { loggerToForward.Log(logMessage); } } }
private static string FormatLog(ILogMessage message) { //$filename($row,$column): $error_type $error_code: $error_message //C:\Code\Paradox\sources\assets\SiliconStudio.Assets.CompilerApp\PackageBuilder.cs(89,13,89,70): warning CS1717: Assignment made to same variable; did you mean to assign something else? var builder = new StringBuilder(); builder.Append(message.Module); builder.Append(": "); builder.Append(message.Type.ToString().ToLowerInvariant()).Append(" "); builder.Append((clock.ElapsedMilliseconds * 0.001).ToString("0.000")); builder.Append("s: "); builder.Append(message.Text); return builder.ToString(); }
/// <summary> /// Return a unique fingerprint string for this message (presumably an error) /// </summary> /// <remarks> /// <para>This is an important method. Think of the fingerprint like a hashcode. /// All instances of the same logical error should have the same fingerprint. /// Each unique error should have a unique fingerprint. /// </para> /// <para>This implementation makes the reasonably good assumption that a fingerprint /// should be based on product + application + caption + classname + category.</para> /// <para>There are three main weaknesses to this approach:</para> /// <para>1. If the caption varies across instances, each will be assigned /// a unique fingerprint. To minimize this, make sure to put all dynamic fields such as /// parameter values in the message description, not the caption.</para> /// <para>2. Localization. If the caption is localized, each language will result /// in a unique fingerprint.</para> /// <para>3. If the caption is too generic (ex., null reference exception) different /// errors might be erroneously grouped together.</para> /// </remarks> private static string GetFingerprint(ILogMessage message) { ISessionSummary summary = message.Session.Summary; StringBuilder builder = new StringBuilder(); builder.AppendFormat("Loupe Error Fingerprint:\r\n"); builder.AppendFormat("Product: {0}\r\n", summary.Product); builder.AppendFormat("Application: {0}\r\n", summary.Application); builder.AppendFormat("Caption: {0}\r\n", message.Caption); builder.AppendFormat("ClassName: {0}\r\n", message.ClassName); builder.AppendFormat("Category: {0}\r\n", message.CategoryName); string hash = GetHash(builder.ToString()); return hash; }
/// <inheriteddoc /> protected override void OnLog(ILogMessage msg, ref bool success) { var handler = MessageReceived; if (handler == null) { return; } var e = new LogEventArgs(msg) { Handled = true, }; handler(this, e); success = e.Handled; }
protected override void LogRaw(ILogMessage logMessage) { buildStep.Logger.Log(logMessage); if (mainLogger != null) { mainLogger.Log(logMessage); } if (StepLogger != null) { lock (StepLogger) { StepLogger.Log(logMessage); } } }
public void WriteMessage( ILogMessage message ) { if (_disposed) { return; } if (message == null) { return; } PrepareFileForWrite(); _current.WriteMessage(message); }
public CommonMessageSettings( IMessageSerializer messageSerializer, string separatorMessage, string firstMessage, string lastMessage ) { if (messageSerializer == null) { throw new ArgumentNullException("messageSerializer"); } if (separatorMessage == null) { throw new ArgumentNullException("separatorMessage"); } if (firstMessage == null) { throw new ArgumentNullException("firstMessage"); } if (lastMessage == null) { throw new ArgumentNullException("lastMessage"); } if (!separatorMessage.EndsWith(Environment.NewLine)) { separatorMessage += Environment.NewLine; } if (!firstMessage.EndsWith(Environment.NewLine)) { firstMessage += Environment.NewLine; } if (!lastMessage.EndsWith(Environment.NewLine)) { lastMessage += Environment.NewLine; } SeparatorMessage = new ServiceLogMessage(messageSerializer, string.Empty, separatorMessage); FirstMessage = new ServiceLogMessage(messageSerializer, string.Empty, firstMessage); LastMessage = new ServiceLogMessage(messageSerializer, string.Empty, lastMessage); }
protected override void ExportLogMessage(IRepositoryContext context, ISession session, ILogMessage message) { if (message.Severity == LogMessageSeverity.Verbose) Write("{0} {1}\r\n", message.Timestamp, message.Caption.Trim()); else { var severity = message.Severity.ToString(); if (severity.StartsWith("Info") || severity.StartsWith("Warn")) severity = severity.Substring(0, 4); else severity = severity.ToUpperInvariant(); Write("{0} {2} {1}\r\n", message.Timestamp, message.Caption.Trim(), severity); } if (string.IsNullOrEmpty(message.Description) == false) { Write("{0}\r\n", message.Description.Trim()); } IExceptionInfo currentException = message.Exception; if (currentException != null) { if (Config.IncludeExceptionDetails) { var label = "EXCEPTION"; while (currentException != null) { Write("{0}: {1} - {2}\r\n", label, currentException.TypeName, currentException.Message.Trim()); currentException = currentException.InnerException; label = "INNER EXCEPTION"; } } else { Write("{0}: {1}\r\n", currentException.TypeName, currentException.Message.Trim()); } WriteLine(); } }
/// <summary> /// Process a user's Add Defect request /// </summary> public DialogResult AddDefect(IRepositoryContext context, IList<ILogMessage> messages, RepositoryController controller, FBApi api) { // It shouldn't happen that we get called with no messages selected, // but check for it anyway. if (messages.Count <= 0) return DialogResult.Cancel; UseWaitCursor = true; //store off our initial state m_Context = context; m_Controller = controller; m_LogMessages = messages; int lastMessageIndex = messages.Count - 1; m_PrimaryMessage = messages[lastMessageIndex]; ErrorInfo errorInfo = new ErrorInfo(m_PrimaryMessage); m_Fingerprint = errorInfo.Fingerprint; //Blank our display ClearDisplay(); //now go to the background to initialize it ThreadPool.QueueUserWorkItem(AsyncInitializeData, api); DialogResult result = ShowDialog(); if (result == DialogResult.OK) { Submit(api); } else { m_Context.Log.Verbose(LogCategory, "User canceled dialog, no changes will be submitted", null); } return DialogResult; }
public void Log(ILogMessage logMessage) { Console.WriteLine(logMessage); }
public abstract void Log(ILogMessage message);
public Task LogAsync(ILogMessage message) { _Log(message.Level, message.Message); return(Task.CompletedTask); }
// Public members public override void Log(ILogMessage message) { lock (lockObject) { base.Log(message); } }
public void ReportError(ILogMessage message) { var errorListEntry = new ErrorListTableEntry(message); RunTaskOnUI(() => ErrorListTableDataSource.Value.AddNuGetEntries(errorListEntry)); }
public void Log(ILogMessage message) { lock (_lock) _ctx.Information($"NuGet ({message.Level}) - Code: {message.Code} - Project: {message.ProjectPath} - {message.Message}"); }
/// <summary> /// Measures the field of the message to present in the column and updates the <see cref="Width"/> property. /// </summary> /// <param name="message">Message to measure to adjust the width of the column.</param> public abstract void UpdateWidth(ILogMessage message);
/// <summary> /// Gets whether the given log message is a <see cref="LogMessageType.Debug"/> message type /// </summary> /// <param name="logMessage">The log message.</param> /// <returns><c>true</c> if the given log message is a <see cref="LogMessageType.Debug"/> message, <c>false</c> otherwise.</returns> public static bool IsDebug([NotNull] this ILogMessage logMessage) { return(logMessage.Type == LogMessageType.Debug); }
/// <summary> /// Gets whether the given log message is a <see cref="LogMessageType.Verbose"/> message type /// </summary> /// <param name="logMessage">The log message.</param> /// <returns><c>true</c> if the given log message is a <see cref="LogMessageType.Verbose"/> message, <c>false</c> otherwise.</returns> public static bool IsVerbose([NotNull] this ILogMessage logMessage) { return(logMessage.Type == LogMessageType.Verbose); }
public void Log(ILogMessage logMessage) { Console.WriteLine(logMessage); }
public void Log(ILogMessage message) => System.Diagnostics.Debug.WriteLine($"{message.Level.ToString().ToUpper()}: {message.Message}");
protected void Log(ILogMessage obj) { var handler = MessageLogged; if (handler != null) handler(obj); }
/// <summary> /// Logs a LogMessage. /// </summary> /// <param name="logger"></param> /// <param name="message"></param> public static void Log(this ILogger logger, ILogMessage message) { message.Log(logger); }
/// <summary> /// Log messages to VS. This is optimized to determine /// if the message needs to be logged before moving to the /// UI thread. /// </summary> public sealed override Task LogAsync(ILogMessage logMessage) { Log(logMessage); return(Task.CompletedTask); }
public Task LogAsync(ILogMessage message) { this.Log(message); return(Task.CompletedTask); }
/// <summary> /// Gets whether the given log message is a <see cref="LogMessageType.Info"/> message type /// </summary> /// <param name="logMessage">The log message.</param> /// <returns><c>true</c> if the given log message is a <see cref="LogMessageType.Info"/> message, <c>false</c> otherwise.</returns> public static bool IsInfo([NotNull] this ILogMessage logMessage) { return(logMessage.Type == LogMessageType.Info); }
/// <summary> /// Appends output of the current column for the specified line to the specified string builder. /// </summary> /// <param name="message">Message containing the field to format.</param> /// <param name="builder">String builder to append the output of the current column to.</param> /// <param name="line">Line number to append (zero-based).</param> /// <returns>true, if there are more lines to process; otherwise false.</returns> public abstract bool Write(ILogMessage message, StringBuilder builder, int line);
/// <summary> /// Gets whether the given log message is a <see cref="LogMessageType.Warning"/> message type /// </summary> /// <param name="logMessage">The log message.</param> /// <returns><c>true</c> if the given log message is a <see cref="LogMessageType.Warning"/> message, <c>false</c> otherwise.</returns> public static bool IsWarning([NotNull] this ILogMessage logMessage) { return(logMessage.Type == LogMessageType.Warning); }
public Task LogAsync(ILogMessage message) { Log(message); return(System.Threading.Tasks.Task.CompletedTask); }
/// <summary> /// Gets whether the given log message is a <see cref="LogMessageType.Error"/> message type /// </summary> /// <param name="logMessage">The log message.</param> /// <returns><c>true</c> if the given log message is a <see cref="LogMessageType.Error"/> message, <c>false</c> otherwise.</returns> public static bool IsError([NotNull] this ILogMessage logMessage) { return(logMessage.Type == LogMessageType.Error); }
public LogMessageFormatter(ILogMessage message) { Message = message; }
/// <summary> /// Gets whether the given log message is a <see cref="LogMessageType.Fatal"/> message type /// </summary> /// <param name="logMessage">The log message.</param> /// <returns><c>true</c> if the given log message is a <see cref="LogMessageType.Fatal"/> message, <c>false</c> otherwise.</returns> public static bool IsFatal([NotNull] this ILogMessage logMessage) { return(logMessage.Type == LogMessageType.Fatal); }
public LogMessageViewModel(ILogMessage message, string timeFormat) { msg = message; this.timeFormat = timeFormat; }
/// <summary> /// Gets whether the given log message is at least as severe as the given severity level. /// </summary> /// <param name="logMessage">The log message.</param> /// <param name="minSeverity">The minimal severity level.</param> /// <returns><c>true</c> if the given log message is at least as severe as the given severity level, <c>false</c> otherwise.</returns> public static bool IsAtLeast([NotNull] this ILogMessage logMessage, LogMessageType minSeverity) { return(logMessage.Type >= minSeverity); }
public abstract Task LogAsync(ILogMessage message);
/// <summary> /// Gets whether the given log message is at most as severe as the given severity level. /// </summary> /// <param name="logMessage">The log message.</param> /// <param name="maxSeverity">The maximal severity level.</param> /// <returns><c>true</c> if the given log message is at most as severe as the given severity level, <c>false</c> otherwise.</returns> public static bool IsAtMost([NotNull] this ILogMessage logMessage, LogMessageType maxSeverity) { return(logMessage.Type <= maxSeverity); }
protected override void LogRaw(ILogMessage logMessage) { // Discard the message }
public void Log(ILogMessage message) { this.Log(message.Level, message.Message); }
private async Task LogToVSAsync(bool reportProgress, bool showAsOutputMessage, ILogMessage logMessage, RestoreOperationProgressUI progress) { var verbosityLevel = GetMSBuildLevel(logMessage.Level); // Progress dialog if (reportProgress) { await progress?.ReportProgressAsync(logMessage.Message); } // Output console if (showAsOutputMessage) { await WriteLineAsync(verbosityLevel, logMessage.FormatWithCode()); } }
public Task LogAsync(ILogMessage message) => Task.Run(() => Log(message));
public void Log(ILogMessage logMessage) { if (treatWarningsAsErrors && logMessage.Type == LogMessageType.Warning) logMessage.Type = LogMessageType.Error; Console.WriteLine(logMessage); }
/// <summary> /// This method upgrades the warning to an error if the project wide warning properties have set the code in WarningsAsErrors or /// set TreatWarningsAsErrors to true /// </summary> /// <param name="message">ILogMessage to be logged as an error or warning.</param> /// <returns>bool indicating if the message should be suppressed.</returns> private void UpgradeWarningToErrorIfNeeded(ILogMessage message) { WarningPropertiesCollection.ApplyProjectWideWarningsAsErrorProperties(message, WarningProperties); }
public void Log(ILogMessage logMessage) { if (treatWarningsAsErrors && logMessage.Type == LogMessageType.Warning) logMessage.Type = LogMessageType.Error; loggerToForward.Log(logMessage); }
/// <summary> /// Decides if the log should be passed to the inner logger. /// </summary> /// <param name="message">ILogMessage to be logged.</param> /// <returns>bool indicating if this message should be logged.</returns> private bool DisplayMessage(ILogMessage message) { return(message.Level >= VerbosityLevel); }
private void LogMessage(ILogMessage obj) { Logger.Log(obj); }
private void Log(ILogMessage obj) { dynViewModel.Model.Logger.Log(obj); }