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


C# Severity.ToString方法代码示例

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


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

示例1: WriteOutput

        //public JobLogger(IConfig config, int skipFrames)
        //{
        //    _pageName = config.SessionContext.PageName;
        //    _aspSessionId = config.SessionContext.AspSessionId;
        //    _sessionId = config.SessionContext.SessionId;
        //    _clientIp = config.SessionContext.ClientIp;
        //    _syslog = GetLogger(config, skipFrames);
        //}
        protected override void WriteOutput(string message, Severity severity, LogTo logTo)
        {
            if (logTo.HasFlag(LogTo.File))
            {
                _fileHandler.WriteMessage(message, severity.ToString());
            }
            if (logTo.HasFlag(LogTo.DataBase))
            {
                _logDataAccess.InsertMessage(message, (int) severity);
            }
            if (logTo.HasFlag(LogTo.Console))
            {
                //TODO:implements console
                switch(severity)
                {
                    case Severity.Message:
                        Console.ForegroundColor = ConsoleColor.White;
                        break;
                    case Severity.Warning:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;
                    case Severity.Error:
                        Console.ForegroundColor = ConsoleColor.Red;
                        break;
                    default:
                        Console.ForegroundColor = ConsoleColor.White;
                        break;
                }

                Console.WriteLine("{0} {1}", DateTime.Now.ToShortDateString(), message);
            }
        }
开发者ID:dhuallanca,项目名称:TestRepository,代码行数:40,代码来源:JobLogger.cs

示例2: PickColor

		protected virtual ConsoleColor PickColor(Severity level, out string levelText)
		{
			bool isDetail = ((int)level & 1) != 0;
			bool implicitLevel = level < PrintSeverityAt || isDetail;
			ConsoleColor color;

			if (level >= Severity.CriticalDetail)
				color = isDetail ? ConsoleColor.DarkMagenta : ConsoleColor.Magenta;
			else if (level >= Severity.ErrorDetail)
				color = isDetail ? ConsoleColor.DarkRed : ConsoleColor.Red;
			else if (level >= Severity.WarningDetail)
				color = isDetail ? ConsoleColor.DarkYellow : ConsoleColor.Yellow;
			else if (level >= Severity.NoteDetail)
				color = isDetail ? ConsoleColor.Gray : ConsoleColor.White;
			else if (level >= Severity.DebugDetail)
				color = isDetail ? ConsoleColor.DarkCyan : ConsoleColor.Cyan;
			else if (level >= Severity.VerboseDetail)
				color = isDetail ? ConsoleColor.DarkCyan : ConsoleColor.DarkCyan;
			else
				color = Console.ForegroundColor;

			levelText = implicitLevel ? null : level.ToString().Localized();
			_lastColor = color;
			return color;
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:25,代码来源:BasicSinks.cs

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

示例4: ExceptionLog

 public ExceptionLog(Exception exception, string source, string method, Severity severity, string title = "")
     : this()
 {
     Type = exception.GetType().Name;
     StackTrace = exception.StackTrace;
     Source = string.IsNullOrEmpty(source) ? exception.Source : source;
     Severity = severity.ToString();
     Message = exception.Message;
     InnerException = exception.InnerException != null ? exception.InnerException.ToString() : string.Empty;
     AdditionalInfo = FormatExceptionData(exception.Data);
     TargetSite = exception.TargetSite == null ? "" : exception.TargetSite.Name;
     Title = string.IsNullOrEmpty(title) ? method : title;
 }
开发者ID:TokleMahesh,项目名称:XLog,代码行数:13,代码来源:ExceptionLog.cs

示例5: logdata

 public void logdata(string logfile, string data, bool logtodb, Severity severity)
 {
     if (logtofile)
     {
         System.IO.File.AppendAllText(logfile, Environment.NewLine + "------------------------------------------------------------------------------------------------");
         System.IO.File.AppendAllText(logfile, string.Format("{0}Timestamp: {1}", Environment.NewLine, DateTime.Now));
         System.IO.File.AppendAllText(logfile, string.Format("{0}Message: {1}", Environment.NewLine, data));
         System.IO.File.AppendAllText(logfile, string.Format("{0}Severity: {1}", Environment.NewLine, severity.ToString()));
         System.IO.File.AppendAllText(logfile, Environment.NewLine + "------------------------------------------------------------------------------------------------");
     }
     if (logtodb)
     {
         //insertIntoJobEventLog(data, job, severity);
     }
 }
开发者ID:shekar348,项目名称:1PointOne,代码行数:15,代码来源:Logger.cs

示例6: Log

        public override bool Log(string Message, Severity severity = Severity.Info)
        {
            try
            {
                string LogFileName = Directory.GetCurrentDirectory() + "LogFile.txt";

                File.AppendAllText(LogFileName, string.Format("Priority({0}) > {1}{2}", severity.ToString(), Message, Environment.NewLine));

            /*
            OR

                    StreamWriter SW = null;
                    try
                    {
                        if (!File.Exists(LogFileName))
                            SW = File.CreateText(LogFileName);
                        else
                            SW = File.AppendText(LogFileName);

                        SW.WriteLine(string.Format("Priority({0}) > {1}", PriorityToText(severity), Message));
                        SW.Close();
                    }
                    finally
                    {
                        if (SW != null)
                            SW.Dispose();
                    }
            */
                return true;
            }
            catch
            {
                return false;
                throw new NotImplementedException();
            }
        }
开发者ID:aik-jahoda,项目名称:OndrasLearningSolutions,代码行数:36,代码来源:Reewer.Logging.cs

示例7: LogEngineHealthEvent

        /// <summary>
        /// Logs engine health event
        /// </summary>
        internal void LogEngineHealthEvent(Exception exception,
                             Severity severity,
                             int id,
                             Dictionary<String, String> additionalInfo)
        {
            Dbg.Assert(exception != null, "Caller should validate the parameter");

            LogContext logContext = new LogContext();
            logContext.EngineVersion = Version.ToString();
            logContext.HostId = Host.InstanceId.ToString();
            logContext.HostName = Host.Name;
            logContext.HostVersion = Host.Version.ToString();
            logContext.RunspaceId = InstanceId.ToString();
            logContext.Severity = severity.ToString();
            if (this.RunspaceConfiguration == null)
            {
                logContext.ShellId = Utils.DefaultPowerShellShellID;
            }
            else
            {
                logContext.ShellId = this.RunspaceConfiguration.ShellId;
            }
            MshLog.LogEngineHealthEvent(
                logContext,
                id,
                exception,
                additionalInfo);
        }
开发者ID:40a,项目名称:PowerShell,代码行数:31,代码来源:LocalConnection.cs

示例8: Write

        protected virtual void Write(int msg, [NotNull] string text, Severity severity, [NotNull] string fileName, TextSpan textSpan, [NotNull] string details)
        {
            if (IgnoredMessages.Contains(msg))
            {
                return;
            }

            if (!string.IsNullOrEmpty(details))
            {
                text += ": " + details;
            }

            var fileInfo = !string.IsNullOrEmpty(fileName) ? fileName : "scc.cmd";

            var projectDirectory = Configuration.Get(Constants.Configuration.ProjectDirectory);
            if (!string.IsNullOrEmpty(projectDirectory))
            {
                if (fileInfo.StartsWith(projectDirectory, StringComparison.OrdinalIgnoreCase))
                {
                    fileInfo = fileInfo.Mid(projectDirectory.Length + 1);
                }
            }

            var lineInfo = textSpan.Length == 0 ? $"({textSpan.LineNumber},{textSpan.LinePosition})" : $"({textSpan.LineNumber},{textSpan.LinePosition},{textSpan.LineNumber},{textSpan.LinePosition + textSpan.Length})";

            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write($"{fileInfo}{lineInfo}: ");

            switch (severity)
            {
                case Severity.Warning:
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    break;
                case Severity.Error:
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;
                default:
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    break;
            }

            Console.Write(severity.ToString().ToLowerInvariant());

            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write(" SCC{0}: ", msg.ToString("0000"));

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(text);
        }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:49,代码来源:TraceService.cs

示例9: ErrorReported

 public override void ErrorReported(ScriptSource source, string message, SourceSpan span, int errorCode, Severity severity)
 {
     Errors.AppendLine(string.Format("{0}:{1} - {2} at Line {3}", new object[] { severity.ToString(), errorCode.ToString(), message, span.Start.Line.ToString() }));
 }
开发者ID:0ks3ii,项目名称:IronWASP,代码行数:4,代码来源:ScriptErrorReporter.cs

示例10: WriteCore

		public void WriteCore(Severity type, object context, string text)
		{
			string loc = MessageSink.ContextToString(context);
			if (!string.IsNullOrEmpty(loc))
				text = loc + ": " + text;
			Trace.WriteLine(text, type.ToString());
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:7,代码来源:BasicSinks.cs

示例11: GetLogContext

        /// <summary>
        /// Generate LogContext structure based on executionContext and invocationInfo passed in.
        /// 
        /// LogContext structure is used in log provider interface. 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <param name="invocationInfo"></param>
        /// <param name="severity"></param>
        /// <returns></returns>
        private static LogContext GetLogContext(ExecutionContext executionContext, InvocationInfo invocationInfo, Severity severity)
        {
            if (executionContext == null)
                return null;

            LogContext logContext = new LogContext();

            string shellId = executionContext.ShellID;

            logContext.ExecutionContext = executionContext;
            logContext.ShellId = shellId;
            logContext.Severity = severity.ToString();

            if (executionContext.EngineHostInterface != null)
            {
                logContext.HostName = executionContext.EngineHostInterface.Name;
                logContext.HostVersion = executionContext.EngineHostInterface.Version.ToString();
                logContext.HostId = (string)executionContext.EngineHostInterface.InstanceId.ToString();
            }

            logContext.HostApplication = String.Join(" ", Environment.GetCommandLineArgs());

            if (executionContext.CurrentRunspace != null)
            {
                logContext.EngineVersion = executionContext.CurrentRunspace.Version.ToString();
                logContext.RunspaceId = executionContext.CurrentRunspace.InstanceId.ToString();

                Pipeline currentPipeline = ((RunspaceBase)executionContext.CurrentRunspace).GetCurrentlyRunningPipeline();
                if (currentPipeline != null)
                {
                    logContext.PipelineId = currentPipeline.InstanceId.ToString(CultureInfo.CurrentCulture);
                }
            }

            logContext.SequenceNumber = NextSequenceNumber;

            try
            {
                if (executionContext.LogContextCache.User == null)
                {
                    logContext.User = Environment.UserDomainName + "\\" + Environment.UserName;
                    executionContext.LogContextCache.User = logContext.User;
                }
                else
                {
                    logContext.User = executionContext.LogContextCache.User;
                }
            }
            catch (InvalidOperationException)
            {
                logContext.User = Logging.UnknownUserName;
            }

            System.Management.Automation.Remoting.PSSenderInfo psSenderInfo =
                    executionContext.SessionState.PSVariable.GetValue("PSSenderInfo") as System.Management.Automation.Remoting.PSSenderInfo;
            if (psSenderInfo != null)
            {
                logContext.ConnectedUser = psSenderInfo.UserInfo.Identity.Name;
            }

            logContext.Time = DateTime.Now.ToString(CultureInfo.CurrentCulture);

            if (invocationInfo == null)
                return logContext;

            logContext.ScriptName = invocationInfo.ScriptName;
            logContext.CommandLine = invocationInfo.Line;

            if (invocationInfo.MyCommand != null)
            {
                logContext.CommandName = invocationInfo.MyCommand.Name;
                logContext.CommandType = invocationInfo.MyCommand.CommandType.ToString();

                switch (invocationInfo.MyCommand.CommandType)
                {
                    case CommandTypes.Application:
                        logContext.CommandPath = ((ApplicationInfo)invocationInfo.MyCommand).Path;
                        break;
                    case CommandTypes.ExternalScript:
                        logContext.CommandPath = ((ExternalScriptInfo)invocationInfo.MyCommand).Path;
                        break;
                }
            }

            return logContext;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:95,代码来源:MshLog.cs

示例12: FormatMessage

		public static string FormatMessage(Severity type, object context, string format, params object[] args)
		{
			string loc = LocationString(context);
			string formatted = Localize.From(format, args);
			if (string.IsNullOrEmpty(loc))
				return Localize.From(type.ToString()) + ": " + formatted;
			else
				return loc + ": " + 
				       Localize.From(type.ToString()) + ": " + formatted;
		}
开发者ID:default0,项目名称:LoycCore,代码行数:10,代码来源:IMessageSink.cs

示例13: Report

 public static void Report(Exception ex, Dictionary<string, string> args, Severity type)
 {
     if (Active) {
         if (Logging.DebugOutline) {
             #region Debug Output
             string key = "";
             string value = "";
             if (args != null && args.Keys.Count>0){//args?.Keys.Count > 0) {
                 key = args.Keys.First ();
                 value = args [key];
             }
             Debug.WriteLine (string.Format("[{0}] {1}: {2};\n\rStackTrace:\n\r{3}", type.ToString(), key,value,ex != null ? ex.ToString():""));
             #endregion
         }
     }
 }
开发者ID:ralexey-egocms,项目名称:SmartDock,代码行数:16,代码来源:LoggingService.cs

示例14: Source

 /// <summary>
 /// Sets up the source object
 /// </summary>
 /// <param name="parent">The parent of the source</param>
 /// <param name="severity">Source severity</param>
 public Source( Tag parent, Severity severity )
 {
     m_Severity = severity;
     m_Name = severity.ToString( );
     m_FullName = ( parent.IsRootTag ? m_Name : parent.FullName + "." + m_Name );
 }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:11,代码来源:Source.cs

示例15: CheckReportForSeverity

 /// <summary>
 /// Checks if the report has the severity.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="value">The value.</param>
 /// <returns><c>true</c> if there is a violation with that severity, <c>false</c> otherwise.</returns>
 private static bool CheckReportForSeverity(XmlDocument document, Severity value)
 {
     var nodes = document.SelectNodes("/CodeItRightReport/Violations/Violation[Severity='" + value.ToString() + "']");
     return nodes.Count > 0;
 }
开发者ID:derrills1,项目名称:ccnet_gitmode,代码行数:11,代码来源:CodeItRightTask.cs


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