示例#1
0
文件: LogEvent.cs 项目: zelk/straaw
		internal LogEvent(LogEvent sourceLogEvent, long endTimeStamp)
		{
			TimeStamp = endTimeStamp;
			ScopeTime = endTimeStamp - sourceLogEvent.TimeStamp;
			Logger = sourceLogEvent.Logger;
			MemberName = sourceLogEvent.MemberName;
			FileName = sourceLogEvent.FileName;
			LineNumber = sourceLogEvent.LineNumber;
			LogLevel = sourceLogEvent.LogLevel;
			AppName = sourceLogEvent.AppName;
			Message = sourceLogEvent.Message;
		}
		protected override void WriteLine(string textLine, LogEvent logEvent)
		{
			lock (this)
			{
				_streamWriter.WriteLine(textLine);
//				var count = Interlocked.Increment(ref _writeLineCallCount);
//				if (count%_lineCountPerFlush == 0)
//				{
					_streamWriter.Flush();
//				}
			}
		}
示例#3
0
文件: LogManager.cs 项目: zelk/straaw
		internal void Log(LogEvent logEvent)
		{
			lock(_logWritersPerLogger)
			{
				List<LogWriter> logWriters;
				if (!_logWritersPerLogger.TryGetValue(logEvent.Logger, out logWriters))
				{
					throw new NullReferenceException("Logger is missing from LogManager.");
				}

				foreach (var logWriter in logWriters)
				{
					logWriter.Log(logEvent);
				}
			}
		}
示例#4
0
		public void Dispose()
		{
			var logEvent = new LogEvent(_logEvent, Logger.Stopwatch.ElapsedMilliseconds);
			_logger.Log(logEvent);
		}
示例#5
0
		internal LoggerScope(Logger logger, LogEvent logEvent)
		{
			_logger = logger;
			_logEvent = logEvent;
		}
示例#6
0
		protected override void WriteLine(string textLine, LogEvent logEvent)
		{
			Console.WriteLine(textLine);
		}
示例#7
0
文件: Logger.cs 项目: zelk/straaw
				formatString,
				arg0,
				arg1,
				arg2,
				arg3,
				arg4,
				arg5,
				arg6,
				arg7,
				arg8,
				arg9
			);
			_logManager.Log(logEvent);
		}

		public void Debug
		(
			string formatString,
			object arg0 = null,
			object arg1 = null,
			object arg2 = null,
			object arg3 = null,
			object arg4 = null,
			object arg5 = null,
			object arg6 = null,
			object arg7 = null,
			object arg8 = null,
			object arg9 = null,
			string overflowGuard = UniqueString,
			[CallerMemberName] string memberName = "",
			[CallerFilePath] string sourceFilePath = "",
			[CallerLineNumber] int sourceLineNumber = 0
		)
		{
			if (overflowGuard != UniqueString)
				throw new OverflowException("Only 10 arguments are supported");

			var logLevel = LogLevel.Debug;
			if (_minimumLogLevel.Ordinal > logLevel.Ordinal)
				return;

			var logEvent = new LogEvent
			(
				Stopwatch.ElapsedMilliseconds,
				this,
				_loggingType,
				memberName,
				sourceFilePath,
				sourceLineNumber,
				logLevel,
示例#8
0
文件: Logger.cs 项目: zelk/straaw
				arg0,
				arg1,
				arg2,
				arg3,
				arg4,
				arg5,
				arg6,
示例#9
0
文件: LogWriter.cs 项目: zelk/straaw
		protected abstract void WriteLine(string textLine, LogEvent logEvent);
示例#10
0
文件: LogWriter.cs 项目: zelk/straaw
		internal void Log(LogEvent logEvent)
		{
			if (GetLogLevel(logEvent.Logger).Ordinal <= logEvent.LogLevel.Ordinal)
			{
				WriteLine(_logFormatter(logEvent), logEvent);
			}
		}