示例#1
0
        /// <summary>
        /// Write an error record to the log
        /// </summary>
        /// <param name="Record">The actual error record as powershell wrote it</param>
        /// <param name="FunctionName">The name of the function writing the error</param>
        /// <param name="ModuleName">The name of the module the function writing the error came from</param>
        /// <param name="Tags">The tags that were assigned to the error event</param>
        /// <param name="Timestamp">When was the error written</param>
        /// <param name="Message">What message was passed to the user</param>
        /// <param name="Runspace">The runspace the message was written from</param>
        /// <param name="ComputerName">The computer the error was written on</param>
        public static void WriteErrorEntry(ErrorRecord[] Record, string FunctionName, string ModuleName, List <string> Tags, DateTime Timestamp, string Message, Guid Runspace, string ComputerName)
        {
            DbatoolsExceptionRecord tempRecord = new DbatoolsExceptionRecord(Runspace, ComputerName, Timestamp, FunctionName, ModuleName, Tags, Message);

            foreach (ErrorRecord rec in Record)
            {
                tempRecord.Exceptions.Add(new DbatoolsException(rec, FunctionName, Timestamp, Message, Runspace, ComputerName));
            }

            if (ErrorLogFileEnabled)
            {
                OutQueueError.Enqueue(tempRecord);
            }
            if (ErrorLogEnabled)
            {
                ErrorRecords.Enqueue(tempRecord);
            }

            DbatoolsExceptionRecord tmp;

            while ((MaxErrorCount > 0) && (ErrorRecords.Count > MaxErrorCount))
            {
                ErrorRecords.TryDequeue(out tmp);
            }
        }
示例#2
0
 /// <summary>
 /// Retrieves a copy of the Error stack
 /// </summary>
 /// <returns>All errors thrown by functions using the message or flowcontrol system</returns>
 public static DbatoolsExceptionRecord[] GetErrors()
 {
     DbatoolsExceptionRecord[] temp = new DbatoolsExceptionRecord[ErrorRecords.Count];
     ErrorRecords.CopyTo(temp, 0);
     return(temp);
 }