123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #region --------------- Copyright Dresser Wayne Pignone -------------
- /*
- * $Log: /Wrk/WayneLibraries/Wrk/Log/ErrorLogEntry.cs $
- *
- * 2 08-02-13 9:26 Mattias.larsson
- * FxCop fixes.
- */
- #endregion
- using System.Text;
- using System.Diagnostics.CodeAnalysis;
- namespace Wayne.Lib.Log
- {
- /// <summary>
- /// Base LogEntry for Errors.
- /// </summary>
- public class ErrorLogEntry : EventLogEntry
- {
- #region Fields
- private ErrorLogSeverity severity;
- #endregion
- #region Construction
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="entity"></param>
- /// <param name="severity"></param>
- /// <param name="logObject">The object to log.</param>
- [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "object")]
- public ErrorLogEntry(IIdentifiableEntity entity, ErrorLogSeverity severity, object logObject)
- : base(entity, logObject)
- {
- this.severity = severity;
- }
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="entity"></param>
- /// <param name="severity"></param>
- /// <param name="logObject">The object to log.</param>
- /// <param name="category"></param>
- [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "object")]
- public ErrorLogEntry(IIdentifiableEntity entity, ErrorLogSeverity severity, object logObject, object category)
- : base(entity, logObject, category)
- {
- this.severity = severity;
- }
- #endregion
- #region Properties
- /// <summary>
- /// The keyword "***ERROR" put in the log file.
- /// </summary>
- public const string LogPrefix = "***ERROR";
- /// <summary>
- /// The severity of the error.
- /// </summary>
- public ErrorLogSeverity Severity
- {
- get { return severity; }
- }
- #endregion
- #region Methods: AppendTextToStringBuilder
- /// <summary>
- /// Appends the object to log to a StringBuilder-output.
- /// </summary>
- /// <param name="logWriter">The logwriter to be used for logging.</param>
- /// <param name="output">The StringBuilder.</param>
- /// <param name="indentLength">The indent to be used if many lines.</param>
- /// <param name="isFirstLine">Is this the first line to log?</param>
- /// <param name="indent">A string holding a generated indent-text (=a number of spaces). Use AppendIndent() to append the indent.</param>
- internal override void AppendToStringBuilder(LogWriter logWriter, StringBuilder output,
- int indentLength, ref bool isFirstLine, ref string indent)
- {
- // Add the keyword.
- output.Append(LogPrefix);
- output.Append(": ");
- // Add the generic entry info.
- StringLogObject.AppendObjectToStringBuilder(LogObject, output, logWriter, indentLength, ref isFirstLine, ref indent);
- }
- #endregion
- }
- }
|