예제 #1
0
		/// <summary>
		/// Dispatches the RequestMoreInformation event to
		/// all connected event handlers (if any).
		/// </summary>
		/// <param name="type">The type.</param>
		/// <param name="originalMessage">The original message.</param>
		/// <param name="message">The message.</param>
		/// <param name="t">The t.</param>
		/// <param name="userDefinedInformation">The user defined information.</param>
		/// <returns></returns>
		private string DispatchRequestMoreInformationEvents(
			LogType type,
			string originalMessage,
			string message,
			Exception t,
			ILoggingUserDefinedInformation userDefinedInformation )
		{
			if ( requestMoreInformationEvents == null ||
				requestMoreInformationEvents.Count <= 0 )
			{
				return message;
			}
			else
			{
				string cumulatedMessage = message;

				foreach ( LogCentralRequestMoreInformationEventHandler evt
					in requestMoreInformationEvents )
				{
					if ( evt != null )
					{
						LogCentralRequestMoreInformationEventArgs args =
							new LogCentralRequestMoreInformationEventArgs(
							loggerName,
							type,
							originalMessage,
							message,
							t,
							userDefinedInformation );

						evt( this, args );

						// Yes, add additional information.
						cumulatedMessage =
							CombineMoreInformationMessage(
							cumulatedMessage,
							args.MoreInformationMessage );
					}
				}

				return cumulatedMessage;
			}
		}
예제 #2
0
		/// <summary>
		/// Provide my own handler for basic information.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="ZetaLib.Core.Logging.LogCentralRequestMoreInformationEventArgs"/> instance containing the event data.</param>
		/// <remarks>
		/// This handler is called when the logging framework wants more
		/// information about the current environment.
		/// </remarks>
		private void LogCentral_RequestMoreInformationNetworkEnvironment(
			object sender,
			LogCentralRequestMoreInformationEventArgs e )
		{
			if ( e.Type == LogType.Error ||
				e.Type == LogType.Fatal ||
				e.Type == LogType.Warn )
			{
				e.MoreInformationMessage =
					Environment.NewLine +
					Environment.NewLine +
					@"------------->" +
					Environment.NewLine +

					LoggingInformation.NetworkEnvironment +

					Environment.NewLine +
					@"<-------------" +
					Environment.NewLine +
					Environment.NewLine;
			}
		}