本文整理汇总了C#中Severity类的典型用法代码示例。如果您正苦于以下问题:C# Severity类的具体用法?C# Severity怎么用?C# Severity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Severity类属于命名空间,在下文中一共展示了Severity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculatesPriorityValueCorrectly
public void CalculatesPriorityValueCorrectly(Facility facility, Severity severity, int expectedPriorityValue)
{
var msg = CreateMinimalSyslogMessage(facility, severity);
string serializedMsg = sut.Serialize(msg);
Assert.Equal(String.Format("<{0}>1 - - - - -", expectedPriorityValue), serializedMsg);
}
示例2: FormatError
public FormatError(byte[] buffer, int ptr, Severity sev, string msg)
{
_buf = buffer;
_offset = ptr;
_severity = sev;
_message = msg;
}
示例3: LoggerMessage
public LoggerMessage(Severity severity, int threadId, string threadName, string message)
{
Severity = severity;
ThreadId = threadId;
ThreadName = threadName;
Message = message;
}
示例4: PreProcess
private static void PreProcess(Severity severity, string additionalMessage, Exception exception)
{
var callStack = new StackTrace(1, true);
var stackFrame = callStack.GetFrame(1);
var log = new Log
{
MethodName = stackFrame.GetMethod().Name,
ClassName = stackFrame.GetMethod().DeclaringType.Name,
ApplicationName = stackFrame.GetMethod().DeclaringType.Assembly.GetName().Name,
LineNumber = stackFrame.GetFileLineNumber(),
Severity = (int)severity,
Message = $"Message: {additionalMessage ?? ""}"
};
if (exception.IsNotNull())
{
log.Message += $" Exception: {(exception.IsNotNull() ? exception.ToString() : "")}";
}
using (var ctx = new ApplicationDbContext())
{
ctx.Logs.Add(log);
ctx.SaveChanges();
}
}
示例5: TrackTrace
public void TrackTrace(string message, Severity severity, IDictionary<string, string> properties)
{
LogEventLevel level = LogEventLevel.Verbose;
switch (severity)
{
case Severity.Off:
return;
case Severity.Error:
level = LogEventLevel.Error;
break;
case Severity.Warning:
level = LogEventLevel.Warning;
break;
case Severity.Verbose:
case Severity.Verbose2:
case Severity.Verbose3:
level = LogEventLevel.Verbose;
break;
}
if (_client.IsEnabled(level))
{
var logProperties = new List<LogEventProperty>();
if (properties != null)
logProperties.AddRange(properties.Select(x => new LogEventProperty(x.Key, new ScalarValue(x.Value))));
_client.Write(new LogEvent(DateTimeOffset.UtcNow, level, null,
new MessageTemplate("{message}", new []{new TextToken(message)}), logProperties));
}
}
示例6: RuleAttribute
public RuleAttribute(string key, Severity severity, string title, bool isActivatedByDefault)
{
Key = key;
Title = title;
Severity = severity;
IsActivatedByDefault = isActivatedByDefault;
}
示例7: Log
private static void Log(Severity severity, string message)
{
if (_logAction != null)
_logAction(severity, message);
else
Console.WriteLine($"{severity}: {message}");
}
示例8: Add
public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity)
{
base.Add(sourceUnit, message, span, errorCode, severity);
Console.Error.WriteLine("{0}({1}:{2}): {3}: RB{4}: {5}", sourceUnit.Name, span.Start.Line, span.Start.Column,
severity, errorCode, message);
}
示例9: AiReportOneObject
public AiReportOneObject(HitObjectBase h, BeenCorrectedDelegate corrected, Severity severity, string information, int weblink, GameMode Mode = GameMode.All)
: base(h.StartTime, severity, information, weblink, corrected, Mode)
{
this.h1 = h;
RelatedHitObjects.Add(h);
}
示例10: Log
private static void Log(string str, Severity sev)
{
string header = string.Empty;
switch (sev)
{
case Severity.TRACE:
header = "TT ##";
break;
case Severity.INFO:
header = "II ##";
break;
case Severity.WARNING:
header = "WW ##";
break;
case Severity.ERROR:
header = "EE ##";
break;
case Severity.STEPIN:
header = ">> ##";
break;
case Severity.STEPOUT:
header = "<< ##";
break;
}
Reporter.Log(header + str + Environment.NewLine);
}
示例11: Filtered
public static IStatusAppender Filtered(IStatusAppender baseAppender, Severity[] severities)
{
if (severities == null) { throw new ArgumentNullException("severities"); } // $NON-NLS-1
if (baseAppender == null || object.ReferenceEquals(baseAppender, StatusAppender.Null)) {
return StatusAppender.Null;
} else if (severities.Length == 0) {
return StatusAppender.Null;
} else {
// 2^0 = 1 (None)
// 2^1 = 2 (Error)
// 2^2 = 4 (Warning)
// 2^3 = 8 (Information)
int result = 0;
for (int i = 0; i < severities.Length; i++) {
result &= (int) (Math.Pow(2, (int) severities[i]));
if (result >= 2 + 4 + 8) { // all have been set or more
return baseAppender;
}
}
bool appendInfos = (result & 8) > 0;
bool appendWarnings = (result & 4) > 0;
bool appendErrors = (result & 2) > 0;
return new FilteredStatusAppender(baseAppender, appendErrors, appendWarnings, appendInfos);
}
}
示例12: Item
protected Item( Severity severity, string message,
object targetItem )
{
this.severity = severity;
this.message = message ?? string.Empty;
this.targetItem = targetItem;
}
示例13: Log
/// <summary>
/// Log a message. The current logging level is used to determine
/// if the message is appended to the configured appender
/// or if it is ignored.
/// </summary>
/// <param name="category">The category to which this log statement belongs.</param>
/// <param name="s">The severity of the logging message.</param>
/// <param name="errorMsg">A concise description of the problem encountered.</param>
/// <param name="args">Variable values that are to be captured with the logging statement.</param>
public static void Log(Severity s, string errorMsg, params object[] args)
{
if (args != null && args.Length > 0)
LogMessage(s, Format(s.ToString() + ": " + errorMsg, args), null);
else
LogMessage(s, errorMsg, null);
}
示例14: ParseIssues
private List<ValidationIssue> ParseIssues(XContainer document, string rootName, string listName, string tagName, Severity severity)
{
var elements = from e in document.Descendants(_namespace + rootName) select e;
var issues = new List<ValidationIssue>();
foreach (var element in elements)
{
foreach (var list in element.Descendants(_namespace + listName))
{
foreach (var errorElement in list.Descendants(_namespace + tagName))
{
var issue = new ValidationIssue { Severity = severity };
if (errorElement.Descendants(_namespace + "line").Any())
issue.Row = int.Parse(errorElement.Descendants(_namespace + "line").First().Value);
if (errorElement.Descendants(_namespace + "col").Any())
issue.Column = int.Parse(errorElement.Descendants(_namespace + "col").First().Value);
if (errorElement.Descendants(_namespace + "message").Any())
{
issue.Title = errorElement.Descendants(_namespace + "message").First().Value;
issue.MessageId = Encoding.UTF8.GetString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(issue.Title)));
}
issues.Add(issue);
}
}
}
return issues;
}
示例15: LogMessage
public LogMessage(string message, IContext context, Severity severity)
{
Message = message;
Severity = severity;
Context = context;
Time = DateTime.Now;
}