log() public static method

Add string to mama log at specified mama level.
/// The logging level is invalid. ///
public static log ( MamaLogLevel level, string text ) : void
level MamaLogLevel /// The level to log at. ///
text string /// The log message. ///
return void
Example #1
0
        private static void onDestroy(IntPtr nativeHandle, IntPtr closure)
        {
            // Obtain the handle from the closure
            GCHandle handle = (GCHandle)closure;

            // Extract the impl from the handle
            MamaPublisher pub = (MamaPublisher)handle.Target;

            Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINE, "DotNet.onDestroy: pub=" + pub);

            // Use the impl to invoke the error callback
            if (null != pub)
            {
                // Invoke the callback
                pub.mCallback.onDestroy(pub);
                handle.Free();
            }
            pub.NativeHandle = IntPtr.Zero;
        }
Example #2
0
        /// <summary>
        /// This function will store the supplied wrapper and return an object
        /// that can be passed into the native layer as a closure.
        /// This should then be passed to the RemoveWrapper function to access
        /// the object whenever the native callback is invoked.
        /// </summary>
        /// <param name="wrapper">
        /// The wrapper object to store.
        /// </param>
        /// <returns>
        /// The handle that can be passed to the native layer.
        /// </returns>
        internal IntPtr StoreWrapper(MamaCallbackWrapper <TCallback, TDelegate> wrapper)
        {
            // Returns
            long ret = 0;

            // Acquire the mutex
            mStoreMutex.WaitOne();
            try
            {
                // Get the next Id
                mNextId++;

                // This will become the handle
                ret = mNextId;

                // Add the wrapper to the store using the Id as the key
                mStore.Add(ret, wrapper);
            }

            finally
            {
                // Release the mutex
                mStoreMutex.ReleaseMutex();
            }

            // Write a log
            if (MamaLogLevel.MAMA_LOG_LEVEL_FINEST == Mama.getLogLevel())
            {
                // Write details of the object that has bee added
                string message = string.Format("MamaCallbackStore: Wrapper stored for key {0} for callback {1}.", ret, wrapper.Callback.ToString());
                Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINEST, message);

                // Write the number of items
                message = string.Format("MamaCallbackStore: Store now contains {0} items.", mStore.Count);
                Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINEST, message);
            }

            /* Return the next Id as the handle. */
            return(new IntPtr(ret));
        }
Example #3
0
        /// <summary>
        /// This function will remove a wrapper object from the store and return it
        /// to the caller. This object should then be disposed by the caller.
        /// </summary>
        /// <param name="handle">
        /// Handle returned from the StoreWrapper function.
        /// </param>
        /// <returns>
        /// The callback wrapper associated with the supplied handle.
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown if the corresponding wrapper is not in the store.
        /// </exception>
        internal MamaCallbackWrapper <TCallback, TDelegate> RemoveWrapper(IntPtr handle)
        {
            // Returns
            MamaCallbackWrapper <TCallback, TDelegate> ret = null;

            // The object handle is the key
            long key = handle.ToInt64();

            // Acquire the mutex
            mStoreMutex.WaitOne();
            try
            {
                // Get the wrapper from the store
                ret = mStore[key];

                // Remove the object from the store
                mStore.Remove(key);
            }

            finally
            {
                // Release the mutex
                mStoreMutex.ReleaseMutex();
            }

            // Write a log
            if (MamaLogLevel.MAMA_LOG_LEVEL_FINEST == Mama.getLogLevel())
            {
                // Write details of the object that has been removed
                string message = string.Format("MamaCallbackStore: Wrapper removed for key {0} for callback {1}.", key, ret.Callback.ToString());
                Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINEST, message);

                // Write the number of items
                message = string.Format("MamaCallbackStore: Store now contains {0} items.", mStore.Count);
                Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINEST, message);
            }

            return(ret);
        }