本文整理汇总了C#中Log.Warning方法的典型用法代码示例。如果您正苦于以下问题:C# Log.Warning方法的具体用法?C# Log.Warning怎么用?C# Log.Warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log.Warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogMessagesTo
private static void LogMessagesTo(TraceSource traceSource)
{
var log = new Log(traceSource);
log.Verbose(_verboseMessage);
log.Information(_infoMessage);
log.Warning(_warningMessage);
log.Error(_errorMessage);
traceSource.Flush();
}
示例2: Warning_ExceptionWithMessageFormat
public void Warning_ExceptionWithMessageFormat()
{
LogManager.AddDebugListener();
var log = new Log(typeof (int));
LogMessageEventArgs eventArgs = null;
log.LogMessage += (sender, e) => eventArgs = e;
var exception = new ArgumentNullException("log test");
log.Warning(exception, "additional message {0}", 1);
Assert.IsNotNull(eventArgs);
Assert.AreEqual(log, eventArgs.Log);
Assert.AreEqual(LogEvent.Warning, eventArgs.LogEvent);
Assert.AreEqual(string.Format("additional message 1 | {0}\r\nParameter name: log test", ArgumentNullExceptionText), eventArgs.Message);
}
示例3: Warning_ExceptionWithMessageFormat_ExceptionNull
public void Warning_ExceptionWithMessageFormat_ExceptionNull()
{
LogManager.AddDebugListener();
var log = new Log(typeof (int));
ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Warning(null, "additional message", 1));
}
示例4: Warning_ExceptionWithMessageFormat_MessageFormatNull
public void Warning_ExceptionWithMessageFormat_MessageFormatNull()
{
LogManager.AddDebugListener();
var log = new Log(typeof (int));
var exception = new ArgumentNullException("log test");
log.Warning(exception, null, 1);
}
示例5: Warning_Exception_Null
public void Warning_Exception_Null()
{
LogManager.AddDebugListener();
var log = new Log(typeof (int));
ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Warning((Exception) null));
}
示例6: Warning_ExceptionWithMessage_ExceptionNull
public void Warning_ExceptionWithMessage_ExceptionNull()
{
LogManager.AddDebugListener();
var log = new Log(typeof (int));
ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Warning(null, string.Empty));
}
示例7: Warning_MessageFormat_Null
public void Warning_MessageFormat_Null()
{
LogManager.AddDebugListener();
var log = new Log(typeof (int));
log.Warning((string) null, null);
}
示例8: Warning_MessageFormat
public void Warning_MessageFormat()
{
LogManager.AddDebugListener();
var log = new Log(typeof (int));
LogMessageEventArgs eventArgs = null;
log.LogMessage += (sender, e) => eventArgs = e;
log.Warning("log message {0}", 1);
Assert.IsNotNull(eventArgs);
Assert.AreEqual(log, eventArgs.Log);
Assert.AreEqual(LogEvent.Warning, eventArgs.LogEvent);
Assert.AreEqual("log message 1", eventArgs.Message);
}
示例9: Warning_ExceptionWithMessageFormat_MessageFormatNull
public void Warning_ExceptionWithMessageFormat_MessageFormatNull()
{
LogManager.RegisterDebugListener();
var log = new Log(typeof(int));
var exception = new ArgumentNullException("log test");
ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Warning(exception, null, 1));
}
示例10: CorrectlyLogsMessageWithBraces
public void CorrectlyLogsMessageWithBraces()
{
LogManager.AddDebugListener();
var log = new Log(typeof(int));
log.Warning("This is a string with { and sometimes and ending }");
}
示例11: Warning_Exception
public void Warning_Exception()
{
LogManager.RegisterDebugListener();
var log = new Log(typeof(int));
LogMessageEventArgs eventArgs = null;
log.LogMessage += (sender, e) => eventArgs = e;
var exception = new ArgumentNullException("log test");
log.Warning(exception);
Assert.IsNotNull(eventArgs);
Assert.AreEqual(log, eventArgs.Log);
Assert.AreEqual(LogEvent.Warning, eventArgs.LogEvent);
Assert.AreEqual(string.Format("[System.Int32] {0}\r\nParameter name: log test", ArgumentNullExceptionText), eventArgs.Message);
}
示例12: Warning_MessageFormat_Null
public void Warning_MessageFormat_Null()
{
LogManager.RegisterDebugListener();
var log = new Log(typeof(int));
ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Warning((string)null, null));
}
示例13: Warning_Message
public void Warning_Message()
{
LogManager.RegisterDebugListener();
var log = new Log(typeof(int));
LogMessageEventArgs eventArgs = null;
log.LogMessage += (sender, e) => eventArgs = e;
log.Warning("log message");
Assert.IsNotNull(eventArgs);
Assert.AreEqual(log, eventArgs.Log);
Assert.AreEqual(LogEvent.Warning, eventArgs.LogEvent);
Assert.AreEqual("[System.Int32] log message", eventArgs.Message);
}
示例14: RawTokenize
private static List<Token> RawTokenize(Log log, string file, string text)
{
List<Token> tokens = new List<Token>();
int i = 0, line = 1, lineStart = 0;
while (i < text.Length) {
// Create an error token by default
Token token = new Token {
kind = TokenKind.Error,
text = "",
location = new Location { file = file, line = line, column = i - lineStart + 1 }
};
int start = i;
char c = text[i++];
if (IsNumber(c)) {
// Parse int literal
token.kind = TokenKind.IntLit;
while (i < text.Length && (IsNumber(text[i]) || IsLetter(text[i]))) {
i++;
}
if (i + 1 < text.Length && text[i] == '.' && IsNumber(text[i + 1])) {
// Parse float literal
token.kind = TokenKind.FloatLit;
i += 2;
while (i < text.Length && IsNumber(text[i])) {
i++;
}
}
} else if (IsLetter(c)) {
// Parse identifier
while (i < text.Length && (IsLetter(text[i]) || IsNumber(text[i]))) {
i++;
}
token.kind = TokenKind.Identifier;
} else if (IsSpace(c)) {
// Parse whitespace
i--;
while (i < text.Length && IsSpace(text[i])) {
if (text[i] == '\n') {
token.kind = TokenKind.Newline;
line++;
lineStart = i + 1;
}
i++;
}
if (token.kind == TokenKind.Error) {
continue;
}
} else if (c == '"' || c == '\'') {
// Parse string literal
while (i < text.Length) {
if (text[i] == c) {
i++;
token.kind = (c == '"') ? TokenKind.StringLit : TokenKind.CharLit;
break;
} else if (text[i] == '\\' && i + 1 < text.Length) {
i++;
char escape = text[i++];
switch (escape) {
case 't':
token.text += '\t';
break;
case 'r':
token.text += '\r';
break;
case 'n':
token.text += '\n';
break;
case '\\':
token.text += '\\';
break;
default:
if (escape != c) {
log.Warning(token.location, "string contains invalid escape sequence '\\" + escape + "'");
token.text += "\\" + escape;
} else {
token.text += escape;
}
break;
}
} else {
token.text += text[i++];
}
}
if (token.kind == TokenKind.Error) {
log.Error(token.location, "unterminated " + (c == '\'' ? "character" : "string") + " literal");
break;
}
if (token.kind == TokenKind.CharLit && token.text.Length != 1) {
log.Error(token.location, "invalid character literal");
break;
}
tokens.Add(token);
continue;
} else if (c == '/' && i < text.Length && text[i] == '/') {
// Check for single line comments
while (i < text.Length && text[i] != '\n') {
i++;
}
//.........这里部分代码省略.........
示例15: Warning_Message_Null
public void Warning_Message_Null()
{
LogManager.RegisterDebugListener();
var log = new Log(typeof (int));
log.Warning((string) null);
}