Esempio n. 1
0
        /// <summary>
        ///     Helper method. Appends caller class name to the output message.
        /// </summary>
        /// <param name="outputMessage"></param>
        private static void HandleAppendCallerClassName(
            StringBuilder outputMessage)
        {
            if (!FlagsHelper.IsSet(
                    Instance.DisplayOptions,
                    AppendOptions.ParentClassName))
            {
                return;
            }

            // Get info from call stack.
            var callerStackInfo = new FrameInfo(6);

            if (Instance.qualifiedClassName)
            {
                // Append fully qualified caller class name.
                outputMessage.Append(
                    ", <- " + callerStackInfo.QualifiedClassName + "");
            }
            else
            {
                outputMessage.Append(
                    ", <- " + callerStackInfo.ClassName + "");
            }
        }
Esempio n. 2
0
        private static void DoLogString(
            string format,
            object objectReference,
            params object[] paramList)
        {
            // Return if method is disabled.
            if (!FlagsHelper.IsSet(
                    Instance.EnabledMethods,
                    EnabledMethods.LogString))
            {
                return;
            }

            // Compose log message.
            var message = string.Format(format, paramList);

            // Get info from call stack.
            var stackInfo = new FrameInfo(3);

            // Log message.
            Log(
                message,
                stackInfo,
                objectReference);
        }
Esempio n. 3
0
        /// <summary>
        ///     Adds timestamp to the log message.
        /// </summary>
        /// <param name="outputMessage"></param>
        private static void HandleShowTimestamp(StringBuilder outputMessage)
        {
            if (!FlagsHelper.IsSet(
                    Instance.DisplayOptions,
                    AppendOptions.Timestamp))
            {
                return;
            }

            outputMessage.Append(GetCurrentTimestamp());
            outputMessage.Append(" ");
        }
Esempio n. 4
0
        /// <summary>
        ///     Appends caller method name to the log message.
        /// </summary>
        /// <param name="outputMessage"></param>
        /// <param name="stackInfo"></param>
        private static void HandleAppendMethodName(
            StringBuilder outputMessage,
            FrameInfo stackInfo)
        {
            if (!FlagsHelper.IsSet(
                    Instance.DisplayOptions,
                    AppendOptions.MethodName))
            {
                return;
            }

            outputMessage.Append(string.Format(".{0}", stackInfo.MethodName));
        }
Esempio n. 5
0
        private static void DoLogCall(object objectReference)
        {
            // Return if method is disabled.
            if (!FlagsHelper.IsSet(
                    Instance.EnabledMethods,
                    EnabledMethods.LogCall))
            {
                return;
            }

            // Get info from call stack.
            var stackInfo = new FrameInfo(3);

            Log(
                stackInfo.MethodSignature,
                stackInfo,
                objectReference);
        }
Esempio n. 6
0
        private static void DoLogResult(object objectRererence, object result)
        {
            // Return if method is disabled.
            if (!FlagsHelper.IsSet(
                    Instance.EnabledMethods,
                    EnabledMethods.LogResult))
            {
                return;
            }

            // Compose log message.
            var message = string.Format("[RESULT: {0}]", result);

            // Get info from call stack.
            var stackInfo = new FrameInfo(3);

            // Log message.
            Log(
                message,
                stackInfo,
                objectRererence);
        }
Esempio n. 7
0
        /// <summary>
        ///     Helper method. Appends class name to the output message.
        /// </summary>
        /// <param name="outputMessage"></param>
        /// <param name="frameInfo"></param>
        private static void HandleAppendClassName(
            StringBuilder outputMessage,
            FrameInfo frameInfo)
        {
            if (!FlagsHelper.IsSet(
                    Instance.DisplayOptions,
                    AppendOptions.CallerClassName))
            {
                return;
            }

            if (Instance.qualifiedClassName)
            {
                // Append fully qualified class name.
                outputMessage.Append(
                    ", @ " + frameInfo.QualifiedClassName + "");
            }
            else
            {
                // Append class name.
                outputMessage.Append(", @ " + frameInfo.ClassName + "");
            }
        }