Esempio n. 1
0
        private static string LogApplicationError(DateTime instant, string message, Exception excep, AppInfo info, HeContext context, string moduleName,
                                                  string stackTrace, int overrideEspaceId, int overrideTenantId,
                                                  string overrideEspaceName = null, string overrideApplicationName = null, ObjectKey overrideApplicationKey = null)
        {
            visitsApplicationErrorLog = visitsApplicationErrorLog + 1;
            try {
                AppInfoForStack     infoForStack    = new AppInfoForStack();
                ContextInfoForStack contextForStack = new ContextInfoForStack();

                /* Prevent recursive loop attempt (#534214).
                 * 1st attempt tries to get info for logging (visitsApplicationErrorLog=1)
                 * 2nd attempt tries to log the new exception without getting info for logging (visitsApplicationErrorLog=2)
                 * 3rd attempt don't log the new exception to avoid recursive loops (visitsApplicationErrorLog>=3 */

                if (visitsApplicationErrorLog >= 3)
                {
                    return("");
                }

                /* Captain's Log #666 15:19 19/06/2017
                 * By now, we've concluded we can't properly refactor this without removing some information from our error logs.
                 * As of now, espace version id will no longer be logged on the second passing and we'll always try to fetch the
                 * context info(session id, user id and request tracer info) on the first and second passing, instead of only getting
                 * it at the first passing. To make this work, we must have sure that it never blows up. */
                if (visitsApplicationErrorLog < 2)
                {
                    infoForStack = FillAppInfoStruct(info, overrideEspaceId, overrideTenantId,
                                                     overrideEspaceName, overrideApplicationName, overrideApplicationKey);
                }

                contextForStack = FillContextInfoStruct(context);

                return(ErrorLogDefinition.LogApplicationError(instant, message, excep, moduleName, stackTrace, infoForStack, contextForStack));
            } finally {
                visitsApplicationErrorLog = visitsApplicationErrorLog - 1;
            }
        }