public static string StaticWrite(DateTime instant, string sessionId, int espaceId, int tenantId, int userId, string message, string stack, string environmentInformation, string moduleName, string requestKey, string entrypointName, string actionName, string eSpaceName, string applicationName, ObjectKey applicationKey, string username) { ErrorLogDefinition log = new ErrorLogDefinition(instant, sessionId, espaceId, tenantId, userId, message, stack, environmentInformation, moduleName, Environment.MachineName, requestKey, actionName, entrypointName, eSpaceName, applicationName, applicationKey, username); log.Write(); return(log.Id); }
public static string LogApplicationError(DateTime instant, string message, Exception excep, string moduleName, string stackTrace, AppInfoForStack info, ContextInfoForStack context) { try { if ((excep is HttpException) && ((excep.Message != null) && excep.Message.StartsWith("Error executing child request")) && (excep.InnerException != null)) { excep = excep.InnerException; } if (stackTrace != null) { stackTrace = stackTrace.Replace(Environment.NewLine, ScriptableBuiltInFunction.NewLine()); } string environmentInformation = GetStackEnvironmentInfo(info, context); string extraDetailMessage = ""; // try to generate full stack of the exception to see if we can fit all inner exceptions in a single error entry int countExceptions = 1; if (excep != null && excep.InnerException != null) { stackTrace = GenerateFullStack(excep, out countExceptions); } StringBuilder stack = new StringBuilder(); // create an error message dumping MAX_INNER_EXCEPTION_DEPTH inner exceptions if no stactTrace is provided int maxretries = (stackTrace != null) ? 1 : MAX_INNER_EXCEPTION_DEPTH; while ((excep != null && maxretries-- > 0) || stackTrace != null) { extraDetailMessage = string.Empty; if (stackTrace != null) { stack.Append(stackTrace); // if we are given the stacktrace as a whole, assume the message is also set or included stackTrace = null; } else if (excep.StackTrace != null) { if (message.IsEmpty()) { message = excep.Message ?? string.Empty; } else if (excep != null && excep.Message != null && !message.Contains(excep.Message)) { extraDetailMessage = excep.Message + ScriptableBuiltInFunction.NewLine(); } if (!message.IsEmpty()) { stack.AppendLine(message); } if (!extraDetailMessage.IsEmpty()) { stack.AppendLine(extraDetailMessage); } stack.Append(excep.StackTrace.Replace(Environment.NewLine, ScriptableBuiltInFunction.NewLine())); } // advance to the next inner exception if (excep != null) { excep = excep.InnerException; } } // log dumped inner exceptions stack trace return(ErrorLogDefinition.StaticWrite(instant, context.sessionId, info.espaceId, info.tenantId, context.userId, message, stack.ToString(), environmentInformation, moduleName, context.requestKey, context.entryPointName, context.actionName, info.eSpaceName, info.applicationName, info.applicationKey, context.username)); } catch (Exception writeErrorException) { try { ErrorLogDefinition.StaticWrite(DateTime.Now, context.sessionId, info.espaceId, info.tenantId, context.userId, "Exception in Global.LogError:" + ScriptableBuiltInFunction.NewLine() + writeErrorException.Message, writeErrorException.StackTrace, "Global", info.eSpaceName, info.applicationName, info.applicationKey, context.username); } catch { } } return(String.Empty); }
public ErrorLogDefinition(ErrorLogDefinition obj) : this(obj.Instant, obj.SessionId, obj.EspaceId, obj.TenantId, obj.UserId, obj.Message, obj.Stack, obj.ModuleName, obj.EnvironmentInformation, obj.Server, obj.RequestKey, obj.ActionName, obj.EntrypointName, obj.EspaceName, obj.ApplicationName, obj.ApplicationKey, obj.Username) { }