Example #1
0
        public static void BeginLog(string message)
        {
            if (LoggerData._logging.Equals(true))
            {
                string callingmethod   = string.Empty;
                int    managedthreadid = Thread.CurrentThread.ManagedThreadId;

                StackTrace stackTrace = new StackTrace();
                if (stackTrace != null)
                {
                    StackFrame[] stackFrames = stackTrace.GetFrames();
                    if (stackFrames != null && (stackFrames.Count() >= 1))
                    {
                        callingmethod = ((System.Type)stackFrames[1].GetMethod().ReflectedType).Name + "." + stackFrames[1].GetMethod().Name;
//						System.Diagnostics.Debug.WriteLine(callingmethod);
                    }
                }

                LoggerData loggerdata = new LoggerData(message, System.Environment.TickCount, callingmethod);
                if (_threadtotickcountqueue.ContainsKey(managedthreadid))
                {
                    ((Stack <LoggerData>)_threadtotickcountqueue[managedthreadid]).Push(loggerdata);
                }
                else
                {
                    Stack <LoggerData> queue = new Stack <LoggerData>();
                    queue.Push(loggerdata);
                    _threadtotickcountqueue[managedthreadid] = queue;
                }
            }
        }
Example #2
0
        public static void BeginLog(string message)
        {
            if (LoggerData._logging.Equals(true))
            {
                string callingmethod = string.Empty;
                int managedthreadid = Thread.CurrentThread.ManagedThreadId;

                StackTrace stackTrace = new StackTrace();
                if (stackTrace != null)
                {
                    StackFrame[] stackFrames = stackTrace.GetFrames();
                    if (stackFrames != null && (stackFrames.Count() >= 1))
                    {
                        callingmethod = ((System.Type)stackFrames[1].GetMethod().ReflectedType).Name + "." + stackFrames[1].GetMethod().Name;
            //						System.Diagnostics.Debug.WriteLine(callingmethod);
                    }
                }

                LoggerData loggerdata = new LoggerData(message, System.Environment.TickCount, callingmethod);
                if (_threadtotickcountqueue.ContainsKey(managedthreadid))
                    ((Stack<LoggerData>)_threadtotickcountqueue[managedthreadid]).Push(loggerdata);
                else
                {
                    Stack<LoggerData> queue = new Stack<LoggerData>();
                    queue.Push(loggerdata);
                    _threadtotickcountqueue[managedthreadid] = queue;
                }
            }
        }
Example #3
0
        // #############################################################################################
        // Public interface
        // #############################################################################################

        /** ********************************************************************************************
         * Constructor for domain.
         * @param parent     The parent domain. For root domains, this is null.
         * @param name       The name of the domain. For root domains, this is null.
         **********************************************************************************************/
        public Domain(Domain parent, AString name)
        {
            // store parameters
            this.Name   = name;
            this.Parent = parent;

            // create fields
            SubDomains = new List <Domain>(3);
            Data       = new List <LoggerData>(parent == null ? 2 : parent.Data.Count);

            // if we have a parent, we inherit all logger's verbosities
            if (parent != null)
            {
                foreach (LoggerData ldParent in parent.Data)
                {
                    LoggerData ld = new LoggerData(ldParent.Logger);
                    ld.LoggerVerbosity = ldParent.LoggerVerbosity;
                    ld.Priority        = ldParent.Priority;
                    Data.Add(ld);
                }
            }

            FullPath = new AString();
            Domain dom = this;

            do
            {
                if (dom != this || dom.Parent == null)
                {
                    FullPath.InsertAt("/", 0);
                }
                FullPath.InsertAt(dom.Name, 0);
                dom = dom.Parent;
            }while(dom != null);
        }
Example #4
0
 public RollBarLogger(IOptions <LoggerData> loggerOptions, IOptions <AppSettings> appSettings)
 {
     _logSettings = loggerOptions.Value;
     _appSettings = appSettings.Value;
     RollbarLocator.RollbarInstance.Configure(new RollbarConfig(_logSettings.RollBar.Key)
     {
         Environment = _appSettings.Environment
     });
 }
 public AppWebException(
     string message
     , LoggerData loggerData = null
     , Exception exception   = null
     )
     : base(message, HttpStatusCode.BadRequest, exception)
 {
     Log.Fatal(ExceptionMessage, loggerData, exception ?? this);
 }
 public AppWebException(
     AppWebExceptionType error
     , LoggerData loggerData = null
     , Exception exception   = null
     )
     : base(error.GetMessage(), error.GetHttpCode(), exception)
 {
     Log.Fatal(ExceptionMessage, loggerData, exception ?? this);
 }
 public AppWebException(
     AppWebExceptionType error
     , HttpStatusCode status
     , string customMessage
     , LoggerData loggerData = null
     , Exception exception   = null
     )
     : base(error.GetMessage() + ": " + customMessage, status, exception)
 {
     Log.Fatal(ExceptionMessage, loggerData, exception ?? this);
 }
Example #8
0
        private static bool _IsValid(string sessionId)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(sessionId) == true)
                {
                    DeleteAndInvalidateOldSessions();
                    return(false);
                }

                UserSession userSession = AuthenticationDao.GetUserSession(sessionId);
                if (userSession == null)
                {
                    DeleteAndInvalidateOldSessions();
                    return(false);
                }

                var loggerData = new LoggerData()
                {
                    { "userId", userSession.UserId },
                    { "userSessionId", sessionId },
                    { "userAgent", userSession.UserAgent },
                    { "browserName", userSession.BrowserName },
                    { "operatingSystem", userSession.OS_Name },
                    { "operatingSystemVersion", userSession.OS_Version },
                    { "lastActivity", userSession.LastActivity },
                };

                Log.Info("Possible bad session check", loggerData);

                if (userSession != null)
                {
                    userSession.UpdateLastActivity();
                    AuthenticationDao.SaveOrUpdateUserSession(userSession);
                }

                SetServerSessionAsValidated(userSession.UserSessionId, Guid.Parse(userSession.UserId));

                if (userSession.KeepAlive)
                {
                    SetSessionCookie(userSession.UserSessionId.ToString(), true);
                }
            }
            catch (Exception e)
            {
                Log.Fatal("An error occurred Validating Session", null, e);
                return(false);
            }

            return(true);
        }
Example #9
0
        /** ****************************************************************************************
         * Sets the verbosity for a logger of this domain of all its sub domains to the specified
         * value. If given priority is lower than those actually stored, nothing is set and
         * recursion is stopped.
         *
         * @param loggerNo    The number of the \e Logger to set the \e Verbosity for.
         * @param verbosity   The verbosity value to set.
         * @param priority    The priority of the setting.
         * @return The new \e Verbosity.
         ******************************************************************************************/
        public Verbosity    SetVerbosity(int loggerNo, Verbosity verbosity, int priority)
        {
            LoggerData ld = Data[loggerNo];

            if (priority >= ld.Priority)
            {
                ld.Priority        = priority;
                ld.LoggerVerbosity = verbosity;

                foreach (Domain subDomain in SubDomains)
                {
                    subDomain.SetVerbosity(loggerNo, verbosity, priority);
                }
            }
            return(ld.LoggerVerbosity);
        }
Example #10
0
        /** ****************************************************************************************
         * This is for debugging purposes and for configuration output.
         * E.g. this enables the \e Monodevelop IDE to display object descriptions in the debugger.
         * @returns A human readable string representation of this object.
         ******************************************************************************************/
        public override String ToString()
        {
            tAString._()._(FullPath);
            tAString._('[')._(CntLogCalls, 3)._("] ");

            // get verbosities
            tAString._(" { ");
            for (int i = 0; i < Data.Count; i++)
            {
                LoggerData ld = Data[i];
                tAString._(i != 0 ? ", " : "")
                ._('(')
                ._('[')._(ld.CntLogCalls, 3)._("], ");
                ALox.ToString(ld.LoggerVerbosity, ld.Priority, tAString)
                ._(')');
            }
            return(tAString._(" }").ToString());
        }
Example #11
0
    // #############################################################################################
    // Public interface
    // #############################################################################################

    /** ********************************************************************************************
     * Constructor for domain.
     * @param parent     The parent domain. For root domains, this is null.
     * @param name       The name of the domain. For root domains, this is null.
     **********************************************************************************************/
    public Domain( Domain parent,  AString name )
    {
        // store parameters
        this.Name=      name;
        this.Parent=    parent;

        // create fields
        SubDomains=     new List<Domain>(3);
        Data=           new List<LoggerData>( parent == null ? 2 : parent.Data.Count );

        // if we have a parent, we inherit all logger's verbosities
        if( parent != null )
            foreach( LoggerData ldParent in parent.Data )
            {
                LoggerData ld= new LoggerData( ldParent.Logger );
                ld.LoggerVerbosity= ldParent.LoggerVerbosity;
                ld.Priority=        ldParent.Priority;
                Data.Add( ld );
            }

        FullPath= new AString();
        Domain dom= this;
        do
        {
            if ( dom != this || dom.Parent == null )
                FullPath.InsertAt( "/", 0 );
            FullPath.InsertAt( dom.Name, 0 );
            dom= dom.Parent;
        }
        while( dom != null );
    }
Example #12
0
        /// <summary>
        /// specified error message and a reference to the inner exception that is
        /// the cause of this exception.
        /// </summary>
        ///<param name="objException">The exception that is the cause of the current
        /// exception.  If the innerException parameter is not a <see langword="null"/> reference,
        /// the current exception is raised in a catch block that handles the inner
        /// exception.
        /// </param>
        /// <param name="folderCreationMode">Specifies the folder creation type</param>
        /// <param name="mode">Specifies Product Mode</param>
        /// <param name="errorMode">Specifies Error Mode</param>
        /// <param name="searchId">SearchId for identifier.</param>
        /// <param name="portal">Specifies Portal</param>
        /// <param name="module">Specifies module</param>
        /// <returns> true if log was written successfully; false otherwise</returns>
        public static bool WriteErrorLog(Exception objException, FolderCreationMode folderCreationMode, ProductMode mode, ErrorMode errorMode, string searchId, string portal, string module)
        {
            bool   bReturn      = false;
            string strException = string.Empty;

            try
            {//Inactive conversation
                if (objException.Message.ToUpper().Contains("INACTIVE CONVERSATION"))
                {
                    ClearSessionPool();
                }
                if (string.IsNullOrEmpty(searchId))
                {
                    searchId = DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace("/", "").Replace(" ", "").Replace(":", "").Replace("AM", "").Replace("PM", "");
                }
                var sw = new StringBuilder();
                sw.Append("Source		: "+ objException.Source.ToString().Trim());
                sw.Append("Method		: "+ objException.TargetSite.Name.ToString());
                sw.Append("Date		: "+ DateTime.Now.ToLongTimeString());
                sw.Append("Time		: "+ DateTime.Now.ToShortDateString());
                sw.Append("Error		: "+ objException.Message.ToString().Trim());
                sw.Append("Stack Trace	: "+ objException.StackTrace.ToString().Trim());
                string path = GetErrorLogFilePath(folderCreationMode, searchId);
                WriteException(path, sw.ToString());
                //LogException.clsLogException objLog = new LogException.clsLogException();
                //objLog.WriteException(Mode.ToString(), "Flights", objException.Message);//Module, Product, Error Msg

                //sw = new StreamWriter(GetErrorLogFilePath(folderCreationMode), true);
                //sw.WriteLine("Source		: " + objException.Source.ToString().Trim());
                //sw.WriteLine("Method		: " + objException.TargetSite.Name.ToString());
                //sw.WriteLine("Date		: " + DateTime.Now.ToLongTimeString());
                //sw.WriteLine("Time		: " + DateTime.Now.ToShortDateString());
                //sw.WriteLine("Computer	: " + Dns.GetHostName().ToString());
                //sw.WriteLine("Error		: " + objException.Message.ToString().Trim());
                //sw.WriteLine("Stack Trace	: " + objException.StackTrace.ToString().Trim());
                //sw.WriteLine("^^-------------------------------------------------------------------^^");
                //sw.Flush();
                //sw.Close();

                using (var objLoggerData = new LoggerData())
                {
                    var intMsg = objLoggerData.SaveLogError(searchId, errorMode.ToString(), objException.StackTrace.ToString(), portal, !string.IsNullOrEmpty(module) ? module : mode.ToString());
                }

                #region Send Log / Error Email to admininistrators
                PreEmail.SendLogMail(objException.StackTrace.ToString(), searchId);
                #endregion

                #region Send Log / Error SMS to admininistrators
                if (errorMode.ToString().ToLower() == "critical")
                {
                    using (SendSMS objSendSMS = new SendSMS())
                    {
                        objSendSMS.MobileNo = ConfigurationSettings.AppSettings["ErrorPhoneNoTo"].ToString();
                        objSendSMS.Message  = "New exception occurred on BMT(SearchId : " + searchId + ")";
                        objSendSMS.CallSMS();
                    }
                }
                #endregion


                bReturn = true;
            }
            catch (Exception ex)
            {
                bReturn = false;
            }
            return(bReturn);
        }