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


C# LogCategory.ToString方法代码示例

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


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

示例1: LogEntry

 public static void LogEntry(string message, LogSeverity logSeverity, LogCategory logCategory)
 {
     Logger.Write(new LogEntry
     {
         Title = logCategory.ToString(),
         Message = message,
         Categories = new List<string> { logCategory.ToString() },
         Severity = GetSeverity(logSeverity)
     });
 }
开发者ID:Eugene-Murray,项目名称:Contract_Validus,代码行数:10,代码来源:LogEntryData.cs

示例2: LogEntryAsync

        public static void LogEntryAsync(string message, LogSeverity logSeverity, LogCategory logCategory)
        {
            Task.Factory.StartNew(() => Logger.Write(new LogEntry
            {
	            Title = logCategory.ToString(),
	            Message = message,
	            Categories = new List<string> { logCategory.ToString() },
	            Severity = GetSeverity(logSeverity)
            }));
        }
开发者ID:Eugene-Murray,项目名称:Contract_Validus,代码行数:10,代码来源:LogEntryData.cs

示例3: Log

 public void Log(LogCategory category, string text, params object[] parameters)
 {
     if ((EnabledCategories & category) != 0)
     {
         Console.Write(LogHelpers.GetTimestamp());
         ConsoleColor currentColor = Console.ForegroundColor;
         Console.ForegroundColor = LogHelpers.GetCategoryColor(category);
         Console.Write(category.ToString());
         // Better to restore original than ResetColor
         Console.ForegroundColor = currentColor;
         // TODO: Check Console.BufferWidth and indent wrapping text onto the same level as the end of the timestamp
         // Longest LogCategory is Warning (length is 7 characters)
         // The log will probably mostly contain messages belonging to the
         // category Notice (6 chars). We want a pad of 4 spaces on average
         // and also want the text to be aligned with the last message
         // 7 + 4 = 11 is the max length of (category.ToString() + pad of 4 spaces)
         Console.WriteLine(new string(' ', 11 - category.ToString().Length) + text, parameters);
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:19,代码来源:ConsoleLogProvider.cs

示例4: Log

        public void Log(string msg, LogPriority priority, LogCategory category)
        {
            string padding = "------";

              Console.WriteLine(padding);

              Console.WriteLine(category.ToString());
              Console.WriteLine(priority.ToString());
              Console.WriteLine(msg);

              Console.WriteLine(padding);
        }
开发者ID:bill-mybiz,项目名称:NeroUtils,代码行数:12,代码来源:ConsoleLogger.cs

示例5: Log

        /// <summary>Logs the specified level.</summary>
        /// <param name="level">The logging level.</param>
        /// <param name="category">The category.</param>
        /// <param name="formatMessage">The format message.</param>
        /// <param name="args">The parameters used when format message.</param>
        public static void Log(TrinityLogLevel level, LogCategory category, string formatMessage, params object[] args)
        {
            if (string.IsNullOrEmpty(prefix))
                prefix = string.Format("[Trinity {0}]", Trinity.Instance.Version);

            if (category == LogCategory.UserInformation || level >= TrinityLogLevel.Error || (Trinity.Settings != null && Trinity.Settings.Advanced.LogCategories.HasFlag(category)))
            {
                string msg = string.Format(prefix + "{0} {1}", category != LogCategory.UserInformation ? "[" + category.ToString() + "]" : string.Empty, formatMessage);

                try
                {
                if (args.Length > 0)
                    msg = string.Format(msg, args);
                }
                catch
                {
                    msg = msg + " || " + args;
                }
                var key = new Tuple<LogCategory, TrinityLogLevel>(category, level);

                if (!LastLogMessages.ContainsKey(key))
                    LastLogMessages.Add(key, "");

                var allowDuplicates = Trinity.Settings != null && Trinity.Settings.Advanced != null && Trinity.Settings.Advanced.AllowDuplicateMessages;

                string lastMessage;
                if (LastLogMessages.TryGetValue(key, out lastMessage) && (allowDuplicates || lastMessage != msg))
                {
                    LastLogMessages[key] = msg;

                    switch (level)
                    {
                        case TrinityLogLevel.Error:
                            _Logger.Error(msg);
                            break;
                        case TrinityLogLevel.Info:
                            _Logger.Info(msg);
                            break;
                        case TrinityLogLevel.Verbose:
                            _Logger.Debug(msg);
                            break;
                        case TrinityLogLevel.Debug:
                            LogToTrinityDebug(msg);
                            break;
                    }
                }
            }
        }
开发者ID:mythsya,项目名称:db-plugins,代码行数:53,代码来源:Logger.cs

示例6: Log

 public static void Log(string msg, LogCategory category, int priority, TraceEventType type, string title, IDictionary<string, object> properties, Guid? correlationId)
 {
     if (defaultWriter != null) { if (defaultWriter.IsLoggingEnabled()) { var entry = new LogEntry { Message = msg }; entry.Categories.Add(category.ToString()); entry.RelatedActivityId = correlationId; entry.Title = string.IsNullOrEmpty(title) ? Defaults.DEFAULT_LOG_TITLE : title; entry.Priority = int.MinValue == priority ? Defaults.DEFAULT_LOG_PRIORITY : priority; entry.ExtendedProperties = properties; defaultWriter.Write(entry); }                 else { Trace.WriteLine("Logging is disabled in the configuration."); } } else { System.Diagnostics.Trace.WriteLine("Log Manager is invalid (Null). Dumping the Log entry to trace event."); System.Diagnostics.Trace.WriteLine(string.Format("Msg: {0}\n Category: {1}\n Priority: {2} Title {3} Correlation ID: {4}", msg, category.ToString(), priority.ToString(), title, correlationId.ToString()));  }
 }
开发者ID:SpotLabsNET,项目名称:VMFactory,代码行数:4,代码来源:LogManager.cs

示例7: Log

 public void Log(string message, LogCategory category)
 {
     this.Log(message, category.ToString(), LevelForCategory(category));
 }
开发者ID:MatanShahar,项目名称:IntelliSun,代码行数:4,代码来源:LoggerBase.cs


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