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


C# LogMessage类代码示例

本文整理汇总了C#中LogMessage的典型用法代码示例。如果您正苦于以下问题:C# LogMessage类的具体用法?C# LogMessage怎么用?C# LogMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Log

        public static void Log(string input)
        {
            var endpoint = GlobalHost.ConnectionManager.GetConnectionContext<ExecuteEndPoint>().Connection;
            var logMessage = new LogMessage(input);

            endpoint.Broadcast(logMessage);
        }
开发者ID:JamesTryand,项目名称:ConsolR,代码行数:7,代码来源:Helper.cs

示例2: LogBlockEnd

        public void LogBlockEnd(FunctionId functionId, LogMessage logMessage, int blockId, int delta, CancellationToken cancellationToken)
        {
            var kvLogMessage = logMessage as KeyValueLogMessage;
            if (kvLogMessage == null)
            {
                return;
            }

            try
            {
                // guard us from exception thrown by telemetry
                var telemetryEvent = CreateTelemetryEvent(functionId, End);
                SetBlockId(telemetryEvent, functionId, blockId);

                var durationName = functionId.GetPropertyName(Duration);
                telemetryEvent.SetIntProperty(durationName, delta);

                var cancellationName = functionId.GetPropertyName(CancellationRequested);
                telemetryEvent.SetBoolProperty(cancellationName, cancellationToken.IsCancellationRequested);

                _session.PostEvent(telemetryEvent);
            }
            catch
            {
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:26,代码来源:VSTelemetryLogger.cs

示例3: RegisterDiagnostics

        private static void RegisterDiagnostics(ContainerBuilder builder)
        {
            builder.Register(
                c =>
                {
                    var loggers = c.Resolve<IEnumerable<ILogger>>();
                    Action<LevelToLog, string> action = (p, s) =>
                    {
                        var msg = new LogMessage(p, s);
                        foreach (var logger in loggers)
                        {
                            try
                            {
                                logger.Log(msg);
                            }
                            catch (NLogRuntimeException)
                            {
                                // Ignore it and move on to the next logger.
                            }
                        }
                    };

                    return new SystemDiagnostics(action, null);
                })
                .As<SystemDiagnostics>()
                .SingleInstance();
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:27,代码来源:DependencyInjection.cs

示例4: ProcessMessage

        /// <summary>
        /// Processes the specified log message
        /// </summary>
        /// <param name="message"></param>
        protected override void ProcessMessage(LogMessage message)
        {
            // Call base
            base.ProcessMessage(message);

            // Transform log type and strip the tag
            Imports.OxideNative_LogType logType;
            string msg;
            switch (message.Type)
            {
                case LogType.Debug:
                    logType = Imports.OxideNative_LogType.Debug;
                    msg = message.Message.Replace(" [Debug]", ":");
                    break;
                case LogType.Info:
                    logType = Imports.OxideNative_LogType.Info;
                    msg = message.Message.Replace(" [Info]", ":");
                    break;
                case LogType.Warning:
                    logType = Imports.OxideNative_LogType.Warning;
                    msg = message.Message.Replace(" [Warning]", ":");
                    break;
                case LogType.Error:
                    logType = Imports.OxideNative_LogType.Error;
                    msg = message.Message.Replace(" [Error]", ":");
                    break;
                default:
                    return;
            }

            // Forward it to native
            Imports.OxideNative_WriteLog(logType, msg);
        }
开发者ID:OxideMod,项目名称:OxideNative,代码行数:37,代码来源:NativeLogger.cs

示例5: ErrLog

 public ErrLog(string msg, string location, string state, LogMessage originalMessage)
 {
     ErrorMessage = msg;
     ParserState = state;
     ErrorLocation = location;
     LogData = originalMessage;
 }
开发者ID:taesiri,项目名称:lpSolver,代码行数:7,代码来源:ErrLog.cs

示例6: GetFormatted

		/// <summary>
        ///     Возвращет форматированный текст из представления сообщения <see cref="LogMessage"/>
		/// </summary>
        /// <param name="message">Представление сообщения <see cref="LogMessage"/></param>
        /// <returns>Форматированная строка сообщения</returns>
		protected virtual string GetFormatted(LogMessage message) {
			string text;
			if (!string.IsNullOrEmpty(CustomFormat)) {
				text = Regex.Replace(CustomFormat, @"\$\{(\w+)\}", m =>
					{
						var propName = m.Groups[1].Value;
						var prop = message.GetType().GetProperty(propName);
						if (null != prop) {
							var val = prop.GetValue(message, null);
							if (null == val) {
								return "";
							}
							if (val is DateTime) {
								return ((DateTime) val).ToString("yyyy-MM-dd HH:mm:ss");
							}
							return val.ToString();
						}
						return "";
					});
			}
			else {
				text = message.ToString();
			}
			return text;
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:30,代码来源:BaseLogWriter.cs

示例7: LogFailSafe

		/// <summary>
		/// 	Fail safe UserLog gate to write internal exception without main logging context, but with max guarantee of regestering
		/// 	synchronous
		/// </summary>
		public void LogFailSafe(LogMessage message) {
			if (null == message) {
				return;
			}
			if (string.IsNullOrEmpty(message.Name)) {
				message.Name = "FAILSAFE";
			}
			try {
				StreamWriter wr = null;
				for (var i = 0; i < 100; i++) {
					try {
						wr = new StreamWriter(Path.Combine(EnvironmentInfo.RootDirectory, "failsafelog" + i + ".txt"), true, Encoding.UTF8);
						break;
					}
// ReSharper disable EmptyGeneralCatchClause
					catch (Exception) {}
// ReSharper restore EmptyGeneralCatchClause
				}
				if (null == wr) {
					var tmpfile = Path.GetTempFileName() + ".failsafelog." +
					              DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss", CultureInfo.InvariantCulture) + ".txt";
					wr = new StreamWriter(tmpfile, true, Encoding.UTF8);
				}
				using (wr) {
					wr.WriteLine(message.ToString());
					wr.Flush();
				}
			}
			catch (Exception ex) {
				throw new LogException("even safe mode fails to be executed", ex);
			}
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:36,代码来源:DefaultLogManager.cs

示例8: Log

 public void Log(LogMessage message)
 {
     lock (_lock)
     {
         _wrappedLog.Log(message);
     }
 }
开发者ID:TomPeters,项目名称:chooie,代码行数:7,代码来源:ThreadSafeLog.cs

示例9: Write

 /// <summary>
 /// Writes a message to this logger
 /// </summary>
 /// <param name="msg"></param>
 internal virtual void Write(LogMessage msg)
 {
     // If we're set to process immediately, do so, otherwise enqueue
     if (processmessagesimmediately)
         ProcessMessage(msg);
     else
         messagequeue.Enqueue(msg);
 }
开发者ID:906507516,项目名称:Oxide,代码行数:12,代码来源:Logger.cs

示例10: CreateLogMessage

 /// <summary>
 /// Creates a log message from the specified arguments
 /// </summary>
 /// <param name="type"></param>
 /// <param name="format"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 protected LogMessage CreateLogMessage(LogType type, string format, object[] args)
 {
     LogMessage msg = new LogMessage { Type = type, Message =
         $"{DateTime.Now.ToShortTimeString()} [{type}] {format}"
     };
     if (args.Length != 0) msg.Message = string.Format(msg.Message, args);
     return msg;
 }
开发者ID:906507516,项目名称:Oxide,代码行数:15,代码来源:Logger.cs

示例11: Log

		public override void Log ( LogMessage message )
		{
			Colorize( message.MessageType );
			
			GetWriter( message.MessageType ).WriteLine("{2}", message.DateTime, message.ThreadId, message.MessageText );

			Console.ResetColor();
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:8,代码来源:StdLogListener.cs

示例12: saveLog

 public void saveLog(LogLevel logLevel, string message)
 {
     LogMessage n = new LogMessage (logLevel, message);
     if (_messages.Count >= max) {
         _messages.RemoveAt (0);
     }
     _messages.Add (n);
 }
开发者ID:mauriciosousa,项目名称:creepytracker,代码行数:8,代码来源:Logger.cs

示例13: Log

        /// <summary>
        /// Record the log message to the console.
        /// </summary>
        /// <param name="logMessage">The log message object to record</param>
        protected internal override void Log(LogMessage logMessage)
        {
            if (logMessage == null) return;

            DateTime time = DateTime.FromBinary(logMessage.Time);
            String level = Enum.GetName(typeof(LogLevel), logMessage.Level);
            Console.WriteLine(OutputFormat, time, level, logMessage.Tag, logMessage.Message);
        }
开发者ID:Masson,项目名称:Tiny-Logger,代码行数:12,代码来源:ConsoleLogRecorder.cs

示例14: Display

 public static void Display(LogMessage message)
 {
     writeTimePrefix();
     writeTypePrefix(message.LogType, message.BGColor, message.FGColor);
     for (int i = 0; i < 40 - message.Message.Length; i++)
         message.Message += " ";
     Console.WriteLine(message.Message);
 }
开发者ID:Wroud,项目名称:MCSClasic,代码行数:8,代码来源:Log.cs

示例15: Write

		/// <summary>
		/// 
		/// </summary>
		/// <param name="logmessage"></param>
		public override void Write(LogMessage logmessage)
		{
			base.Write(logmessage);
			if (logmessage.Level >= this.Level){
				Messages.Add(logmessage);
			}
			
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:12,代码来源:CollectionBasedUserLog.cs


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