internal bool CanLogResponse(string operationName) { MessageLogConfig operationMessageLogConfig = this.OperationNameMap[operationName.ToLower()].OperationMessageLogConfig; bool disableLog = operationMessageLogConfig.DisableLog ?? ServiceMessageLogConfig.DisableLog ?? MessageLogConfig.CurrentFrameworkDefaultMessageLogConfig.DisableLog ?? false; if (disableLog) { return(false); } bool logResponse = operationMessageLogConfig.LogResponse ?? ServiceMessageLogConfig.LogResponse ?? MessageLogConfig.CurrentFrameworkDefaultMessageLogConfig.LogResponse ?? false; if (!logResponse) { return(false); } bool isResponseSensitive; switch (EnvironmentUtility.CurrentEnv) { case EnvironmentUtility.TestEnv: case EnvironmentUtility.UatEnv: isResponseSensitive = MessageLogConfig.CurrentFrameworkDefaultMessageLogConfig.IsResponseSensitive ?? false; break; case EnvironmentUtility.ProdEnv: default: isResponseSensitive = operationMessageLogConfig.IsResponseSensitive ?? ServiceMessageLogConfig.IsResponseSensitive ?? MessageLogConfig.CurrentFrameworkDefaultMessageLogConfig.IsResponseSensitive ?? true; break; } return(!isResponseSensitive); }
static MessageLogConfig() { RequestLogMaxSize = DefalutRequestLogMaxSize; ResponseLogMaxSize = DefalutResponseLogMaxSize; FrameworkDefalutMessageLogConfigOfTestEnv = new MessageLogConfig() { IsRequestSensitive = false, IsResponseSensitive = false, LogRequest = true, LogResponse = false, DisableLog = false, }; FrameworkDefalutMessageLogConfigOfUatEnv = new MessageLogConfig() { IsRequestSensitive = false, IsResponseSensitive = false, LogRequest = true, LogResponse = false, DisableLog = false, }; FrameworkDefalutMessageLogConfigOfProdEnv = new MessageLogConfig() { IsRequestSensitive = true, IsResponseSensitive = true, LogRequest = true, LogResponse = false, DisableLog = false, }; FrameworkDefalutMessageLogConfigOfNullEnv = new MessageLogConfig() { IsRequestSensitive = true, IsResponseSensitive = true, LogRequest = false, LogResponse = false, DisableLog = true, }; switch (EnvironmentUtility.CurrentEnv) { case EnvironmentUtility.TestEnv: CurrentFrameworkDefaultMessageLogConfig = FrameworkDefalutMessageLogConfigOfTestEnv; break; case EnvironmentUtility.UatEnv: CurrentFrameworkDefaultMessageLogConfig = FrameworkDefalutMessageLogConfigOfUatEnv; break; case EnvironmentUtility.ProdEnv: CurrentFrameworkDefaultMessageLogConfig = FrameworkDefalutMessageLogConfigOfProdEnv; break; default: CurrentFrameworkDefaultMessageLogConfig = FrameworkDefalutMessageLogConfigOfNullEnv; break; } }
private static MessageLogConfig AttributeToConfig(MessageSensitivityAttribute attribute) { MessageLogConfig config = new MessageLogConfig(); if (attribute == null) { return(config); } switch (attribute.RequestSensitivity) { case SensitivityMode.Default: config.IsRequestSensitive = null; break; case SensitivityMode.Insensitive: config.IsRequestSensitive = false; break; case SensitivityMode.Sensitive: config.IsRequestSensitive = true; break; } switch (attribute.ResponseSensitivity) { case SensitivityMode.Default: config.IsResponseSensitive = null; break; case SensitivityMode.Insensitive: config.IsResponseSensitive = false; break; case SensitivityMode.Sensitive: config.IsResponseSensitive = true; break; } if (attribute.LogResponse) { config.LogResponse = attribute.LogResponse; } if (attribute.DisableLog) { config.DisableLog = attribute.DisableLog; } return(config); }