当前位置: 首页>>代码示例>>C#>>正文


C# Log.Warning方法代码示例

本文整理汇总了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();
 }
开发者ID:Lsuwito,项目名称:SampleApp,代码行数:9,代码来源:LogTest.cs

示例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);
            }
开发者ID:justdude,项目名称:DbExport,代码行数:16,代码来源:LogFacts.cs

示例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));
            }
开发者ID:justdude,项目名称:DbExport,代码行数:7,代码来源:LogFacts.cs

示例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);
            }
开发者ID:justdude,项目名称:DbExport,代码行数:9,代码来源:LogFacts.cs

示例5: Warning_Exception_Null

            public void Warning_Exception_Null()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof (int));

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Warning((Exception) null));
            }
开发者ID:justdude,项目名称:DbExport,代码行数:7,代码来源:LogFacts.cs

示例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));
            }
开发者ID:justdude,项目名称:DbExport,代码行数:7,代码来源:LogFacts.cs

示例7: Warning_MessageFormat_Null

            public void Warning_MessageFormat_Null()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof (int));

                log.Warning((string) null, null);
            }
开发者ID:justdude,项目名称:DbExport,代码行数:7,代码来源:LogFacts.cs

示例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);
            }
开发者ID:justdude,项目名称:DbExport,代码行数:15,代码来源:LogFacts.cs

示例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));
        }
开发者ID:pars87,项目名称:Catel,代码行数:9,代码来源:LogFacts.cs

示例10: CorrectlyLogsMessageWithBraces

            public void CorrectlyLogsMessageWithBraces()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof(int));

                log.Warning("This is a string with { and sometimes and ending }");
            }
开发者ID:justdude,项目名称:DbExport,代码行数:7,代码来源:LogFacts.cs

示例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);
        }
开发者ID:pars87,项目名称:Catel,代码行数:16,代码来源:LogFacts.cs

示例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));
        }
开发者ID:pars87,项目名称:Catel,代码行数:7,代码来源:LogFacts.cs

示例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);
        }
开发者ID:pars87,项目名称:Catel,代码行数:15,代码来源:LogFacts.cs

示例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++;
                }
//.........这里部分代码省略.........
开发者ID:dineshkummarc,项目名称:tinder,代码行数:101,代码来源:Tokenizer.cs

示例15: Warning_Message_Null

            public void Warning_Message_Null()
            {
                LogManager.RegisterDebugListener();
                var log = new Log(typeof (int));

                log.Warning((string) null);
            }
开发者ID:paytonli2013,项目名称:Catel,代码行数:7,代码来源:LogFacts.cs


注:本文中的Log.Warning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。