/// <summary> /// TraceErrorRecord /// </summary> public bool TraceErrorRecord(ErrorRecord errorRecord) { if (errorRecord != null) { Exception exception = errorRecord.Exception; string innerException = "None"; if (exception.InnerException != null) { innerException = exception.InnerException.Message; } ErrorCategoryInfo cinfo = errorRecord.CategoryInfo; string message = "None"; if (errorRecord.ErrorDetails != null) { message = errorRecord.ErrorDetails.Message; } return(DebugChannel.TraceError(PowerShellTraceEvent.ErrorRecord, PowerShellTraceOperationCode.Exception, PowerShellTraceTask.None, message, cinfo.Category.ToString(), cinfo.Reason, cinfo.TargetName, errorRecord.FullyQualifiedErrorId, exception.Message, exception.StackTrace, innerException)); } else { return(DebugChannel.TraceError(PowerShellTraceEvent.ErrorRecord, PowerShellTraceOperationCode.Exception, PowerShellTraceTask.None, "NULL errorRecord")); } }
private static void Log(string p_message, DebugChannel p_channel, DebuggingLevel p_min_level, Indentation p_pre, Indentation p_post) { if (!enable_debugging && p_channel == DebugChannel.Debug) { return; } if (debugging_level < p_min_level) { return; } // If the pre-indentation style is not set to none, perform the necessary indentation/unindentation/reset task first if (p_pre > 0) { if (p_pre == Debugging.Indentation.Indent) { Indent(); } else if (p_pre == Debugging.Indentation.Unindent) { Unindent(); } else if (p_pre == Debugging.Indentation.Reset) { ResetIndentation(); } } // Re-format the message to include the channel tag, timestamp and indentation string message = $"{p_channel.Tag()} {Timestamp} > {Indentation}{p_message}"; // Print the message to the console using the correct colours if (p_channel != DebugChannel.Debug) { Console.WriteLine(message, p_channel.Colour()); } else { // If using the [debug] channel, use the debug stylesheet to allow syntax highlighting Console.WriteLineStyled(message, debug_style_sheet); } // If the post-indentation style is not set to none, perform the necessary indentation/unindentation/reset task if (p_post > 0) { if (p_post == Debugging.Indentation.Indent) { Indent(); } else if (p_post == Debugging.Indentation.Unindent) { Unindent(); } else if (p_post == Debugging.Indentation.Reset) { ResetIndentation(); } } }
public static void Log(DebugChannel dc, string message) { instance.SyncDictionary(); if (!instance.mutedChannels[dc]) { Debug.Log("[" + dc + "]: " + message); } }
public static void Log(this object obj, string message, DebugChannel channel, int severity) { if (SeverityThreshhold > severity) { return; } Debug.LogGen(channel, "[" + severity + "]" + message); }
/// <summary> /// Dispose method. /// </summary> public void Dispose() { if (!disposed) { disposed = true; GC.SuppressFinalize(this); DebugChannel.Dispose(); AnalyticChannel.Dispose(); OperationalChannel.Dispose(); } }
internal static string Tag(this DebugChannel p_channel) { return(p_channel switch { DebugChannel.None => "¦ ¦", DebugChannel.Info => "¦ INFO ¦", DebugChannel.Debug => "¦ DEBUG ¦", DebugChannel.Test => "¦ TEST ¦", DebugChannel.Program => "¦ PROGRAM ¦", DebugChannel.Warning => "¦ WARNING ¦", DebugChannel.Error => "¦ ERROR ¦", DebugChannel.Critical => "¦ CRITICAL ¦", _ => throw new ArgumentOutOfRangeException(nameof(p_channel), p_channel, null) });
/// <summary> /// TraceJob /// </summary> public bool TraceJob(Job job) { if (job != null) { return(DebugChannel.TraceDebug(PowerShellTraceEvent.Job, PowerShellTraceOperationCode.Method, PowerShellTraceTask.None, job.Id.ToString(CultureInfo.InvariantCulture), job.InstanceId.ToString(), job.Name, job.Location, job.JobStateInfo.State.ToString(), job.Command)); } else { return(DebugChannel.TraceDebug(PowerShellTraceEvent.Job, PowerShellTraceOperationCode.Method, PowerShellTraceTask.None, "", "", "NULL job")); } }
/// <summary> /// TraceException /// </summary> public bool TraceException(Exception exception) { if (exception != null) { string innerException = "None"; if (exception.InnerException != null) { innerException = exception.InnerException.Message; } return(DebugChannel.TraceError(PowerShellTraceEvent.Exception, PowerShellTraceOperationCode.Exception, PowerShellTraceTask.None, exception.Message, exception.StackTrace, innerException)); } else { return(DebugChannel.TraceError(PowerShellTraceEvent.Exception, PowerShellTraceOperationCode.Exception, PowerShellTraceTask.None, "NULL exception")); } }
public static void Log(DebugChannel dc, string message, string tag) { instance.SyncDictionary(); bool log = false; if (!instance.mutedChannels[dc]) { log = true; } else { if (instance.allowedTags.Contains(tag)) { log = true; } } if (log) { Debug.Log("[" + dc + "]: " + message + " T: " + tag); } }
/// <summary> /// /// </summary> /// <param name="message"></param> /// <param name="instanceId"></param> /// <returns></returns> public bool WriteMessage(string message, Guid instanceId) { return(DebugChannel.TraceInformational(PowerShellTraceEvent.TraceMessageGuid, PowerShellTraceOperationCode.None, PowerShellTraceTask.None, message, instanceId)); }
/// <summary> /// /// </summary> /// <param name="message1"></param> /// <param name="message2"></param> /// <returns></returns> public bool WriteMessage(string message1, string message2) { return(DebugChannel.TraceInformational(PowerShellTraceEvent.TraceMessage2, PowerShellTraceOperationCode.None, PowerShellTraceTask.None, message1, message2)); }
/// <summary> /// A static extension to receive logs from every point in the code base. /// </summary> /// <param name="message">The message</param> /// <param name="channel">The Channel on where the message is sent(Can be multiple)</param> public static void Log(string message, DebugChannel channel, int importance) { DebugHelper.Log(message, (int)channel, importance); }
public MutedChannel(DebugChannel type, bool muted) { this.type = type; this.muted = muted; }