コード例 #1
0
        }         // Log

        /// <summary>
        ///
        /// The format of the columns will be:  DateTime, Severity, IpAddress, SessionId, ComponentName, MethodName, VmcId, ThreadId, Msg
        /// </summary>
        /// <param name="i_eSeverity"></param>
        /// <param name="i_iVmcId"></param>
        /// <param name="i_sComponent"></param>
        /// <param name="i_sMsg"></param>
        /// <returns></returns>
        public override bool Log(eSeverity i_eSeverity, int i_iVmcId, string i_sComponentName, string i_sMsg)
        {
            bool             bRet = true, bRes = true;
            string           sComponentName = i_sComponentName, sMethodName = "", sVmc = "", sThread = "", sRem = "";
            LoggerThreadInfo oInfo = null;
            StackTrace       oST   = null;

            try
            {
                SetLastError(0, "");
                oInfo = new LoggerThreadInfo();
                oST   = new StackTrace(2);                                              // Skip two frames to avoid the overhead of getting a full stack trace

                // First check to see if we need to log this message or not
                if (i_eSeverity >= m_FilterLevel)
                {
                    bRes = ThreadInfoDictSingleton.GetInstance().TryGetValue(Thread.CurrentThread.Name, out oInfo);                             // Don't need to check return value, we'll just use the empty strings assigned in the constructor.
                    if (!bRes)
                    {
                        // This isn't always an error, some threads (like pooled or event-handlers) won't be named.
                        if (oInfo == null)
                        {
                            oInfo = new LoggerThreadInfo();
                        }
                    }

                    sVmc    = oInfo.m_sVmcId;
                    sThread = oInfo.m_sThreadId;
                    bRes    = ReplaceIndexesIfEmbedded(i_sMsg, ref sVmc, ref sThread, out sRem);

                    if (sComponentName.Length == 0)
                    {
                        sComponentName = oST.GetFrame(0).GetMethod().ReflectedType.FullName;
                    }
                    else
                    {
                        sComponentName = oInfo.m_sComponentName;
                    }
                    sComponentName = StripExtension(sComponentName);

                    sMethodName = oST.GetFrame(0).GetMethod().ReflectedType.FullName + "." + oST.GetFrame(0).GetMethod().Name;
                    oST         = null;

                    m_Logger.Log(ConvertSeverityToNSLevel(i_eSeverity), string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}", i_eSeverity.ToString(), oInfo.m_sIpAddress, oInfo.m_sSessionId, sComponentName, sMethodName, sVmc, sThread, sRem));
                }
            }
            catch (Exception exc)
            {
                bRet = false;
                SetLastError(-1, "Caught exception in Log(3): " + exc.ToString());
                Console.Error.WriteLine(m_sLastError);
            }

            return(bRet);
        }         // Log
コード例 #2
0
        //------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Generate the graph model based on Logic.Graph.
        /// </summary>
        public NotificationDescriptor(NotificationDescriptorType type, NotificationDescriptorOperationType operation, NotificationDescriptorRelatedObject RelatedObject, string DescriptionMessage, eSeverity severity = eSeverity.Info, bool isModal = false)
            : this()
        {
            this.HasRelatedObject = RelatedObject != null;
            this.NotificationDescriptorRelatedObject = RelatedObject;
            this.Type        = type;
            this.Operation   = operation;
            this.Description = DescriptionMessage;
            this.Severity    = severity;
            this.IsModal     = isModal;
        }
コード例 #3
0
        }         // Close

        /// <summary>
        ///
        /// </summary>
        /// <param name="i_Level"></param>
        /// <returns></returns>
        protected eSeverity ConvertLevelToSeverity(Level i_Level)
        {
            eSeverity eRet = eSeverity.Debug;

            switch (i_Level)
            {
            case Level.All:
                eRet = eSeverity.Debug;
                break;

            case Level.Config:
                eRet = eSeverity.Debug;
                break;

            case Level.Debug:
                eRet = eSeverity.Debug;
                break;

            case Level.Exception:
                eRet = eSeverity.Error;
                break;

            case Level.Info:
                eRet = eSeverity.Info;
                break;

            case Level.None:
                eRet = eSeverity.Debug;
                break;

            case Level.Verbose:
                eRet = eSeverity.Debug;
                break;

            case Level.Warning:
                eRet = eSeverity.Warning;
                break;

            default:
                eRet = eSeverity.Debug;
                break;
            }

            return(eRet);
        }         // ConvertLevelToSeverity
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="i_Level"></param>
        /// <returns></returns>
        protected eSeverity ConvertNSLevelToSeverity(NSpring.Logging.Level i_Level)
        {
            eSeverity eRet = m_FilterLevel;

            SetLastError(0, "");

            if (i_Level == NSpring.Logging.Level.All)
            {
                eRet = eSeverity.Debug;
            }
            else if (i_Level == NSpring.Logging.Level.Config)
            {
                eRet = eSeverity.Debug;
            }
            else if (i_Level == NSpring.Logging.Level.Debug)
            {
                eRet = eSeverity.Debug;
            }
            else if (i_Level == NSpring.Logging.Level.Exception)
            {
                eRet = eSeverity.Error;
            }
            else if (i_Level == NSpring.Logging.Level.Info)
            {
                eRet = eSeverity.Info;
            }
            else if (i_Level == NSpring.Logging.Level.None)
            {
                eRet = eSeverity.Crash;
            }
            else if (i_Level == NSpring.Logging.Level.Verbose)
            {
                eRet = eSeverity.Debug;
            }
            else if (i_Level == NSpring.Logging.Level.Warning)
            {
                eRet = eSeverity.Warning;
            }
            // `else` not needed, default assigned above.

            return(eRet);
        }         // ConvertNSLevelToSeverity
コード例 #5
0
        }         // ConvertNSLevelToSeverity

        protected NSpring.Logging.Level ConvertSeverityToNSLevel(eSeverity i_Severity)
        {
            NSpring.Logging.Level lRet = NSpring.Logging.Level.Debug;

            SetLastError(0, "");

            switch (i_Severity)
            {
            case eSeverity.Crash:
                lRet = NSpring.Logging.Level.Exception;
                break;

            case eSeverity.Critical:
                lRet = NSpring.Logging.Level.Exception;
                break;

            case eSeverity.Debug:
                lRet = NSpring.Logging.Level.Debug;
                break;

            case eSeverity.Error:
                lRet = NSpring.Logging.Level.Exception;
                break;

            case eSeverity.Info:
                lRet = NSpring.Logging.Level.Info;
                break;

            case eSeverity.Warning:
                lRet = NSpring.Logging.Level.Warning;
                break;

            default:
                // Default assigned above
                break;
            }

            return(lRet);
        }         // ConvertSeverityToLevel
コード例 #6
0
        public abstract int                     GetErrorCode();         // Returns the ID of the error from the last time Log() returned 'false'.

        // Base class implementations

        /// <summary>
        /// To increase or decrease the amount of logging, set the filter level accordingly.
        /// </summary>
        /// <param name="i_FilterLevel"></param>
        public void SetFilterLevel(eSeverity i_FilterLevel)
        {
            m_FilterLevel = i_FilterLevel;
        }
コード例 #7
0
 public abstract bool            Log(eSeverity i_eSeverity, int i_iVmcId, string i_sComponentName, string i_sMsg);
コード例 #8
0
 // The Log() methods return bools for success, requiring the caller to check the error code or string with the
 // appropriate followup method call.  This was intential to make it easier for scripting languages to use
 // Logger, despite making it slightly clumsier for staticly typed languages.
 public abstract bool            Log(eSeverity i_eSeverity, string i_sMsg);
コード例 #9
0
        }         // ReplaceIndexesIfEmbedded

        /// <summary>
        ///
        /// The format of the columns will be:  DateTime, Severity, IpAddress, SessionId, ComponentName, MethodName, VmcId, ThreadId, Msg
        /// </summary>
        /// <param name="i_eSeverity"></param>
        /// <param name="i_sMsg"></param>
        /// <returns></returns>
        public override bool Log(eSeverity i_eSeverity, string i_sMsg)
        {
            bool             bRet = true, bRes = true;
            string           sComponentName = "", sMethodName = "", sVmc = "", sThread = "", sRem = "";
            LoggerThreadInfo oInfo = null;
            StackTrace       oST   = null;

            try
            {
                SetLastError(0, "");
                oInfo = new LoggerThreadInfo();
                oST   = new StackTrace(2);                                              // Skip two frames to avoid the overhead of getting a full stack trace

                // First check to see if we need to log this message or not
                if (i_eSeverity >= m_FilterLevel)
                {
                    bRes = ThreadInfoDictSingleton.GetInstance().TryGetValue(Thread.CurrentThread.Name, out oInfo);
                    if (!bRes)
                    {
                        // This isn't always an error, some threads (like pooled or event-handlers) won't be named.
//Console.WriteLine("!!!!!{0} In Log(2) TryGetValue failed, calling method '{1}'", DateTime.Now.ToString(), oST.ToString());
                        if (oInfo == null)
                        {
                            oInfo = new LoggerThreadInfo();
                        }
                    }

                    sVmc    = oInfo.m_sVmcId;
                    sThread = oInfo.m_sThreadId;
                    bRes    = ReplaceIndexesIfEmbedded(i_sMsg, ref sVmc, ref sThread, out sRem);

                    if (oInfo.m_sComponentName.Length == 0)
                    {
                        sComponentName = oST.GetFrame(0).GetMethod().Module.Name;
                    }
                    else
                    {
                        sComponentName = oInfo.m_sComponentName;
                    }
                    sComponentName = StripExtension(sComponentName);

                    sMethodName = oST.GetFrame(0).GetMethod().DeclaringType.FullName + "." + oST.GetFrame(0).GetMethod().Name;
                    oST         = null;

                    m_Logger.Log(ConvertSeverityToNSLevel(i_eSeverity), string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}", i_eSeverity.ToString(), oInfo.m_sIpAddress, oInfo.m_sSessionId, sComponentName, sMethodName, sVmc, sThread, sRem));
                }
                else
                {
                    // Below the filter level
                    //Console.WriteLine("Log(2).Log() else - i_eSeverity = '{0}', m_FilterLevel = '{1}'.", i_eSeverity.ToString(), m_FilterLevel.ToString());
                }
            }
            catch (Exception exc)
            {
                bRet = false;
                SetLastError(-1, string.Format("Caught exception in Log(2), calling method '{0}': '{1}'", oST.ToString(), exc.ToString()));
                Console.Error.WriteLine(DateTime.Now.ToString() + " " + m_sLastError);
            }

            return(bRet);
        }         // Log
コード例 #10
0
        }         // Log

        /// <summary>
        ///
        /// </summary>
        /// <param name="i_eSeverity"></param>
        /// <param name="i_iVmcId"></param>
        /// <param name="i_sComponentName"></param>
        /// <param name="i_sMsg"></param>
        /// <returns></returns>
        public override bool Log(eSeverity i_eSeverity, int i_iVmcId, string i_sComponentName, string i_sMsg)
        {
            return(m_Logger.Log(i_eSeverity, i_iVmcId, i_sComponentName, i_sMsg));
        }         // Log
コード例 #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="i_eSeverity"></param>
 /// <param name="i_sMsg"></param>
 /// <returns></returns>
 public override bool Log(eSeverity i_eSeverity, string i_sMsg)
 {
     return(m_Logger.Log(i_eSeverity, i_sMsg));
 }         // Log