示例#1
0
文件: LogEvent.cs 项目: zelk/straaw
		public LogEvent(long timeStamp, Logger logger, Type loggingType, string memberName, string fileName, int lineNumber, LogLevel logLevel, string appName, string formatString, params object[] args)
		{
			TimeStamp = timeStamp;
			ScopeTime = null;
			Logger = logger;
			MemberName = memberName;
			FileName = fileName;
			LineNumber = lineNumber;
			LogLevel = logLevel;
			AppName = appName;
			Message = string.Format(formatString, args);
		}
示例#2
0
文件: LogWriter.cs 项目: zelk/straaw
		public void SetLogLevel(Type type, LogLevel logLevel)
		{
			lock(_logLevelsPerType)
			{
				if (type == null)
					throw new ArgumentNullException();

				_logLevelsPerType.Remove(type);

				if (logLevel != null && logLevel != LogLevel.None)
				{
					_logLevelsPerType.Add(type, logLevel);
				}
			}

			lock(_loggerLogLevelCache)
			{
				_loggerLogLevelCache.Clear();
			}

			_logManager.RecalculateLogLevels(this);
		}
示例#3
0
文件: LogWriter.cs 项目: zelk/straaw
		public void SetLogLevel(string partialClassName, LogLevel logLevel)
		{
			lock (_logLevelsPerPartialName)
			{
				if (partialClassName == null)
					partialClassName = string.Empty;

				_logLevelsPerPartialName.Remove(partialClassName);

				if (logLevel != null && logLevel != LogLevel.None)
				{
					_logLevelsPerPartialName.Add(partialClassName, logLevel);
				}
			}

			lock(_loggerLogLevelCache)
			{
				_loggerLogLevelCache.Clear();
			}

			_logManager.RecalculateLogLevels(this);
		}
示例#4
0
文件: LogManager.cs 项目: zelk/straaw
		private void AddToLogWritersPerLogger(Logger logger, LogWriter logWriter, LogLevel logLevel)
		{
			lock(_logWritersPerLogger)
			{
				List<LogWriter> logWriters;
				if (!_logWritersPerLogger.ContainsKey(logger))
				{
					logWriters = new List<LogWriter>(1);
					_logWritersPerLogger.Add(logger, logWriters);
				}
				else
				{
					if (!_logWritersPerLogger.TryGetValue(logger, out logWriters))
					{
						throw new Exception("Unable to find dictionary key - mutli threading issue?");
					}
				}
				logWriters.Add(logWriter);
			}
		}
示例#5
0
文件: Logger.cs 项目: zelk/straaw
		internal void Log(LogEvent logEvent)
		{
			if (_minimumLogLevel.Ordinal > logEvent.LogLevel.Ordinal)
示例#6
0
文件: Logger.cs 项目: zelk/straaw
				formatString,
				arg0,
				arg1,
				arg2,
				arg3,
				arg4,
				arg5,
				arg6,
				arg7,
				arg8,
				arg9
			);
			_logManager.Log(logEvent);
		}

		public LoggerScope Scope
		(
			LogLevel logLevel,
			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");

			if (_minimumLogLevel.Ordinal > logLevel.Ordinal)
				return null;

			var logEvent = new LogEvent
			(
				Stopwatch.ElapsedMilliseconds,
				this,
				_loggingType,
				memberName,
				sourceFilePath,
				sourceLineNumber,
				logLevel,
				_logManager.AppName,