예제 #1
0
 /// <summary>
 /// Logs a message to indicate that the app was Deactivated using the AppEventMesgType message type (which defaults to MesgType.Signif)
 /// </summary>
 public static void HandleOnDeactivated(Logging.ILogger appLogger)
 {
     appLogger.Emitter(AppEventMesgType).EmitWith("App Deactivated", nvs: new NamedValueSet()
     {
         { "AppEvent", "OnDeactivated" }
     });
 }
예제 #2
0
        /// <summary>
        /// Logs a message to indicate that the app is Stopping using the AppEventMesgType message type (which defaults to MesgType.Signif)
        /// Then runs Logging.ShutdownLogging().
        /// </summary>
        public static void HandleOnExit(Logging.ILogger appLogger)
        {
            appLogger.Emitter(AppEventMesgType).EmitWith("App Stopping", nvs: new NamedValueSet()
            {
                { "AppEvent", "OnExit" }
            });

            Logging.ShutdownLogging();
        }
예제 #3
0
		/// <summary> This is the inner-most implementation method for the Assert helper class.  It implements all of the assertType specific behavior for all assertions that get triggered.</summary>
		private static void AssertCommon(string mesg, AssertType assertType, System.Diagnostics.StackFrame sourceFrame)
		{
			// always log all triggered asserts to the BasicFallbackLog

			string logStr = Fcns.CheckedFormat("{0} at file:'{1}', line:{2}", mesg, sourceFrame.GetFileName(), sourceFrame.GetFileLineNumber());

            if (assertType != AssertType.Log)
            {
                if (EnableBasicFallbackLogging)
                    Logging.BasicFallbackLogging.LogError(logStr);

                if (queuedAssertLogger == null)       // in an MT world we might create a few of these simultaneously.  This is not a problem as the distribution engine supports such a construct so locking is not required here in order to get valid behavior.
                    queuedAssertLogger = new Logging.QueuedLogger("MosaicLib.Utils.Assert");

                queuedAssertLogger.Emitter(DefaultAssertLoggingMesgType).Emit(logStr);
            }

			bool ignoreFault = false;		// intended to be used by debug user to ignore such asserts on a case by case basis

			if (assertType == AssertType.Log)
			{
                if (assertLogger == null)       // in an MT world we might create a few of these simultaneously.  This is not a problem as the distribution engine supports such a construct so locking is not required here in order to get valid behavior.
                    assertLogger = new Logging.Logger("MosaicLib.Utils.Assert");

                assertLogger.Emitter(DefaultAssertLoggingMesgType).Emit(logStr);

				return;
			}
			else if (assertType == AssertType.LogFallback)
			{
				return;	// already done
			}
			else if (assertType == AssertType.ThrowException)
			{
				if (!ignoreFault)
					throw new AssertException(mesg, sourceFrame);

				return;
			}

			if (!ignoreFault)
			{
                // the remaining types always trigger a breakpoint if a debugger is attached and the hosting environment has set the EnabledAssertDebugBreakpoints flag
                if (System.Diagnostics.Debugger.IsAttached && EnableAssertDebugBreakpoints)
					System.Diagnostics.Debugger.Break();
			}
		}