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


C# LogSeverity.ToString方法代码示例

本文整理汇总了C#中LogSeverity.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LogSeverity.ToString方法的具体用法?C# LogSeverity.ToString怎么用?C# LogSeverity.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogSeverity的用法示例。


在下文中一共展示了LogSeverity.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Log

		/// <summary>
		/// Logs the specified severity.
		/// </summary>
		/// <param name="severity">The severity.</param>
		/// <param name="message">The message.</param>
		public void Log(LogSeverity severity, string message)
		{
			RequiresNotNull(message);
			var con = factory.OpenConnection();
			con.ContinueWith(pt =>
			{
				var connection = pt.Result;
				try
				{
					var cmd = connection.CreateCommand();
					cmd.CommandText = "INSERT INTO Log (Id, Timestamp, Severity, Message) VALUES (NEWID(), @time, @sev, @msg)";

					var timestampParameter = cmd.CreateParameter();
					timestampParameter.ParameterName = "@time";
					timestampParameter.Value = DateTime.Now;
					cmd.Parameters.Add(timestampParameter);

					var severityParameter = cmd.CreateParameter();
					severityParameter.ParameterName = "@sev";
					severityParameter.Value = severity.ToString();
					cmd.Parameters.Add(severityParameter);

					var messageParameter = cmd.CreateParameter();
					messageParameter.ParameterName = "@msg";
					messageParameter.Value = message;
					cmd.Parameters.Add(messageParameter);

					cmd.ExecuteNonQuery();
				}
				finally
				{
					connection.Dispose();
				}
			});
		}
开发者ID:jairov4,项目名称:Yorkfield,代码行数:40,代码来源:LogServer.cs

示例2: Log

 /// <summary>
 ///     Log a message
 /// </summary>
 /// <param name="severity">The severity</param>
 /// <param name="source">The source</param>
 /// <param name="message">The message</param>
 public void Log(LogSeverity severity, string source, string message)
 {
     if ((int)severity < (int)MinLogSeverity)
     {
         return;
     }
     Console.WriteLine(severity.ToString() + " " + source + " " + message);
 }
开发者ID:JeanNguon,项目名称:Projet,代码行数:14,代码来源:CustomLogger.cs

示例3: Log

 public void Log(string message, LogSeverity severity, Exception exception)
 {
     Console.WriteLine($"[bond] {severity.ToString().ToUpper()}: {message}");
     if (exception != null)
     {
         Console.WriteLine(exception);
     }
 }
开发者ID:csdahlberg,项目名称:bond,代码行数:8,代码来源:ConsoleLogger.cs

示例4: Log

 public void Log(LogSeverity severity, string source, Exception exception)
 {
     Console.WriteLine(string.Format("Log : {0} - {1} - {2}", severity.ToString(), source, exception.ToString()));
     if (severity == LogSeverity.Error || severity == LogSeverity.Critical)
     {
         Errors.Add(new KeyValuePair<string, Exception>(source, exception));
     }
 }
开发者ID:JeanNguon,项目名称:Projet,代码行数:8,代码来源:FakeLogger.cs

示例5: LogImpl

        /// <excludedoc />
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            message = String.Format("[{0}] {1}", severity.ToString().ToLowerInvariant(), message);

            if (exceptionData != null)
                writer.WriteException(exceptionData, message);
            else
                writer.WriteLine(message);
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:10,代码来源:MarkupStreamLogger.cs

示例6: Log

 public static void Log(string msg,LogSeverity severity=LogSeverity.Information)
 {
     if (ConfigurationHelper.GetLogQueueName() != null)
     {
         if (ConfigurationHelper.GetCurrentSeverityLevel().ToLower() == LogSeverity.Information.ToString().ToLower()
             || (severity.ToString().ToLower() == ConfigurationHelper.GetCurrentSeverityLevel().ToLower()))
         {
             CloudQueueMessage m = new CloudQueueMessage(msg);
             queue.AddMessage(m);
         }                
     }            
 }
开发者ID:stephaneey,项目名称:Eyskens.AutoTaggerGit,代码行数:12,代码来源:LogHelper.cs

示例7: Write

        /// <summary>
        /// Writes to the log.
        /// </summary>
        /// <param name="level">Severity of the log.</param>
        /// <param name="text">Actual (formattable) text.</param>
        /// <param name="args">string.Format arguments.</param>
        public void Write(LogSeverity level, string text, params string[] args)
        {
            if (args.Length > 0) {
                text = string.Format(text, args);
            }

            string[] split = text.Split('\n');

            if (split.Length > 1) {
                foreach (string part in split) {
                    Write(level, part);
                }
                return;
            }

            string line = string.Format(Format, new string[3] {
                DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                level.ToString().PadLeft(8),
                text
            });

            LogFile.WriteLine(line);

            LogEntry logEntry = new LogEntry {
                Text = text,
                Instance = InstanceName,
                Level = level,
                Line = line
            };

            (new Thread(() => {
                foreach (Action<LogEntry> action in LogWrite) {
                    action.Invoke(logEntry);
                }
            })).Start();
        }
开发者ID:flashwave,项目名称:railgun,代码行数:42,代码来源:Logger.cs

示例8: _HandleException

	private static void _HandleException (LogSeverity logLevel, string name, string message, string stackTrace, bool uncaught)
	{
		if (!IsInitialized) {
			PrintLog (LogSeverity.Log, "It has not been initialized.");
			return;
		}

		if (logLevel == LogSeverity.Log) {
			return;
		}

		if ((uncaught && logLevel < _autoReportLogLevel)) {
			PrintLog (LogSeverity.Log, "Not report exception for level {0}", logLevel.ToString ());
			return;
		}

		string type = null;
		string reason = null;

		if (!string.IsNullOrEmpty (message)) {
			try {
				if ((LogSeverity.LogException == logLevel) && message.Contains ("Exception")) {
					Match match = new Regex (@"^(?<errorType>\S+):\s*(?<errorMessage>.*)").Match (message);
						
					if (match.Success) {
						type = match.Groups ["errorType"].Value;
						reason = match.Groups ["errorMessage"].Value.Trim ();
					}
				}
			} catch {

			}

			if (string.IsNullOrEmpty (reason)) {
				reason = message;
			}
		}

		if (string.IsNullOrEmpty (name)) {
			if (string.IsNullOrEmpty (type)) {
				type = string.Format ("Unity{0}", logLevel.ToString ());
			}
		} else {
			type = name;
		}
	
		_reportException (uncaught, type, reason, stackTrace);
	}
开发者ID:zeronely,项目名称:View,代码行数:48,代码来源:BuglyAgent.cs

示例9: LogToConsole

	private static void LogToConsole(LogSeverity level, string message){
		if (!_debugMode && LogSeverity.Log != level) {
			if (level < LogSeverity.LogInfo) {
				return;
			}
		}

		UnityEngine.Debug.LogWarning (string.Format("[BuglyAgent] <{0}> - {1}", level.ToString(), message));
	}
开发者ID:zeronely,项目名称:View,代码行数:9,代码来源:BuglyAgent.cs

示例10: GetLogLevel

 /// <summary>
 /// Gets the log level.
 /// </summary>
 /// <param name="severity">The severity.</param>
 /// <returns>NLog.LogLevel.</returns>
 private NLog.LogLevel GetLogLevel(LogSeverity severity)
 {
     switch (severity)
     {
         case LogSeverity.Debug:
             return NLog.LogLevel.Debug;
         case LogSeverity.Error:
             return NLog.LogLevel.Error;
         case LogSeverity.Warn:
             return NLog.LogLevel.Warn;
         case LogSeverity.Fatal:
             return NLog.LogLevel.Fatal;
         case LogSeverity.Info:
             return NLog.LogLevel.Info;
         default:
             throw new ArgumentException("Unknown LogSeverity: " + severity.ToString());
     }
 }
开发者ID:bigjohn322,项目名称:MediaBrowser,代码行数:23,代码来源:NLogger.cs

示例11: Format

 public string Format(LogSeverity severity, string message)
 {
     return string.Format("{0} [{1}]: {2}", DateTime.Now, 
         severity.ToString(), message);
 }
开发者ID:harpagornis,项目名称:coding.abel.nu,代码行数:5,代码来源:LibraryLogger.cs

示例12: SeverityClass

 /// <summary>Retrieves a CSS class for the given severity level.</summary>
 /// <param name="severity">The severity of the log message.</param>
 public static string SeverityClass(LogSeverity severity)
 {
     return string.Format("{0}_{1}", RootClass, severity.ToString());
 }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:6,代码来源:LogCss.cs

示例13: FormatLogMessage

 /// <summary>
 /// Formats the log message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="severity">The severity.</param>
 /// <param name="messageToken">The message token.</param>
 /// <param name="source">The source.</param>
 /// <returns>System.String.</returns>
 private static string FormatLogMessage(string message, LogSeverity severity, string messageToken = "", string source = "")
 {
     return string.Format(CultureInfo.InvariantCulture, "{0} | {1} | {2} | {3} | {4}{5}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture), severity.ToString().ToUpper(CultureInfo.InvariantCulture), message, source, messageToken, Environment.NewLine);
 }
开发者ID:mparsin,项目名称:Elements,代码行数:12,代码来源:ClientLogger.cs

示例14: _HandleException

 private static void _HandleException(LogSeverity logLevel, string name, string message, string stackTrace, bool uncaught)
 {
     if (!BuglyAgent.IsInitialized)
     {
         BuglyAgent.PrintLog(LogSeverity.Log, "It has not been initialized.", new object[0]);
         return;
     }
     if (logLevel == LogSeverity.Log)
     {
         return;
     }
     if (uncaught && logLevel < BuglyAgent._autoReportLogLevel)
     {
         BuglyAgent.PrintLog(LogSeverity.Log, "Not report exception for level {0}", new object[]
         {
             logLevel.ToString()
         });
         return;
     }
     string text = null;
     string text2 = null;
     if (!string.IsNullOrEmpty(message))
     {
         try
         {
             if (logLevel == LogSeverity.LogException && message.Contains("Exception"))
             {
                 Match match = new Regex("^(?<errorType>\\S+):\\s*(?<errorMessage>.*)").Match(message);
                 if (match.Success)
                 {
                     text = match.Groups["errorType"].Value;
                     text2 = match.Groups["errorMessage"].Value.Trim();
                 }
             }
         }
         catch
         {
         }
         if (string.IsNullOrEmpty(text2))
         {
             text2 = message;
         }
     }
     if (string.IsNullOrEmpty(name))
     {
         if (string.IsNullOrEmpty(text))
         {
             text = string.Format("Unity{0}", logLevel.ToString());
         }
     }
     else
     {
         text = name;
     }
     BuglyAgent._reportException(uncaught, text, text2, stackTrace);
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:56,代码来源:BuglyAgent.cs

示例15: LogToConsole

 private static void LogToConsole(LogSeverity level, string message)
 {
     if (!BuglyAgent._debugMode && level != LogSeverity.Log && level < LogSeverity.LogInfo)
     {
         return;
     }
     try
     {
         BuglyAgent.UnityAgent.Call("printLog", new object[]
         {
             string.Format("[BuglyAgent] <{0}> - {1}", level.ToString(), message)
         });
     }
     catch
     {
     }
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:17,代码来源:BuglyAgent.cs


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