public void then_flattenned_correctly(object input, string expected) { Act(input); var actual = LogCastDocument.ToJson(Request.Route.SerializedValues); actual.Should().Be(expected); }
protected override void SetFields(LogCastDocument document) { _value = new Dictionary <string, int> { { "key1", 23 }, { "key2", 24 } }; document.AddProperty("key", _value); }
public override void Act() { Logger.Warn(TestMessage); Logger.Error(SecondTestMessage); Complete(); _lastLog = ClientMock.LastLog; }
protected virtual void SendTestMessage() { Sut.Send(() => { var doc = new LogCastDocument(); doc.AddProperty("testKey", "testValue"); return(doc); }); }
public void BeforeSend(LogCastDocument document, LogCastContext sourceContext) { var source = OperationContext.Current; if (source != null) { Apply(document, source); } }
public void BeforeSend(LogCastDocument document, LogCastContext sourceContext) { var context = HttpContext.Current; if (context != null) { Apply(document, context); } }
protected override void SetFields(LogCastDocument document) { document.AddProperty("key1", "simple.value1"); document.AddProperty("simple.property", "simple.value2"); document.AddProperty("dictionary.property", new Dictionary <string, string> { { "key", "value" }, { "key.with.dots", "value.with.dots" } }); }
protected override void SetFields(LogCastDocument document) { document.AddProperty("complex_object", new RootObject { Property1 = "rootvalue", Property2 = 23, ChildProperty = new ChildObject { Property3 = "childvalue" } }); }
protected virtual void Apply(LogCastDocument target, HttpContext context) { var root = new Root(); if (Options.IsRequestLogged) { var request = context.Request; var requestData = new Request(); if (Options.LogRequestUri) { requestData.Uri = GetRequestUri(request).AbsoluteUri; } if (Options.LogRequestMethod) { requestData.Method = request.HttpMethod; } if (Options.LogRequestHeaders) { requestData.Headers = CollectHeadersSafely(request.Headers); } if (Options.LogRequestBody) { requestData.Body = ReadRequestBody(request); } root.Request = requestData; } if (Options.IsResponseLogged) { var response = context.Response; var responseData = new Response(); if (Options.LogResponseStatus) { responseData.Status = response.StatusCode; } if (Options.LogResponseHeaders) { responseData.Headers = CollectHeadersSafely(response.Headers); } if (Options.LogResponseBody) { responseData.Body = ReadResponseBody(response); } root.Response = responseData; } if (root.HasData) { target.AddProperty(Root.FieldName, root); } }
public void then_contract_serialized_is_as_expected() { var actualSerialized = LogCastDocument.ToJson(Request.Route); var expected = LogCastDocument.ToJson(new { template = "", controller = (string)null, action = (string)null, values = new {key = "value"} }); actualSerialized.Should().Be(expected); }
protected virtual void Apply <TDestination>(LogCastDocument document, TDestination value) { var existingValue = document.GetProperty <object>(Key); if (existingValue is Dictionary <string, object> childDictionary) { childDictionary[Property.DefaultChildName] = value; } else { document.AddProperty(Name, value, SuppressDefaults); } }
protected virtual void Apply(LogCastDocument target, OperationContext source) { var root = new Root(); if (Options.IsRequestLogged) { var request = new Request(); if (Options.LogCallerAddress) { request.Caller = GetCallerAddress(source.IncomingMessageProperties); } if (Options.LogRequestProperties) { request.Properties = CollectProperties(source.IncomingMessageProperties); } if (Options.LogRequestHttpData) { request.HttpHeaders = CollectHttpRequestHeaders(source.IncomingMessageProperties); } if (Options.LogRequestBody) { request.Body = source.RequestContext?.RequestMessage?.ToString(); } root.Request = request; } if (Options.IsResponseLogged) { var response = new Response(); if (Options.LogResponseProperties) { response.Properties = CollectProperties(source.OutgoingMessageProperties); } if (Options.LogResponseHttpData) { response.HttpHeaders = CollectHttpResponseHeaders(source.OutgoingMessageProperties); } root.Response = response; } if (root.HasData) { target.AddProperty(Root.FieldName, root); } }
protected override void Apply <TDestination>(LogCastDocument document, TDestination value) { var existingValue = document.GetProperty <object>(ParentName); if (existingValue is Dictionary <string, object> childDictionary) { existingValue = null; } else { childDictionary = new Dictionary <string, object>(); document.AddProperty(ParentName, childDictionary); } if (existingValue != null) { childDictionary[Property.DefaultChildName] = existingValue; } childDictionary[Name] = value; }
public static string RemoveSensitiveData(string body) { if (string.IsNullOrWhiteSpace(body)) { return(null); } if (SensitiveInformationKeywords.All(x => body.IndexOf(x, StringComparison.OrdinalIgnoreCase) == -1)) { return(body); } try { var jsonBody = JObject.Parse(body); if (jsonBody == null) { return(Property.Values.Removed); } var keys = ((IDictionary <string, JToken>)jsonBody) .Where(x => SensitiveInformationKeywords.Contains(x.Key, StringComparer.OrdinalIgnoreCase)) .Select(x => x.Key); foreach (var keyValuePair in keys) { jsonBody[keyValuePair] = Property.Values.Removed; } return(LogCastDocument.ToJson(jsonBody)); } catch (Exception) { return(Property.Values.Removed); } }
protected override void SetFields(LogCastDocument document) { document.AddProperty("tab", "\tvalue"); }
protected override void SetFields(LogCastDocument document) { document.AddProperty("key1", "value1"); document.AddProperty("key2", "value2"); }
public override void Arrange() { Accumulator = new PropertyAccumulator(); Document = new LogCastDocument(); }
protected override void SetFields(LogCastDocument document) { document.AddProperty("string", (string)null, true); document.AddProperty("someKey", "someValue"); document.AddProperty("int", 0, true); }
/// <summary> /// Stores property value to the passed <see cref="LogCastDocument"/> /// </summary> protected internal abstract void Apply(LogCastDocument document);
public void BeforeSend(LogCastDocument document, LogCastContext sourceContext) { Apply(document); }
protected abstract void SetFields(LogCastDocument document);
private static string Json(object obj) { return(LogCastDocument.ToJson(obj)); }
public override void Arrange() { Document = new LogCastDocument(); SetFields(Document); }
protected internal sealed override void Apply(LogCastDocument document) { Apply(document, Value); }
/// <summary> /// Aggregates values of the passed properties and stores the result to the passed <see cref="LogCastDocument"/> /// This method is called only when there's more than one property with the same name /// </summary> protected internal abstract void Apply(LogCastDocument document, IEnumerable <LogProperty> properties);
public override void Arrange() { _cut = new LogCastDocument(); }
public void BeforeSend(LogCastDocument document, LogMessage sourceMessage) { Apply(document); }
protected override void SetFields(LogCastDocument document) { document.AddProperty("carriage_return", "\rvalue"); }
private void Apply(LogCastDocument document) { document.AddProperty(Property.Host, _hostData); document.AddProperty(Property.AppVersion, _appVersion); document.AddProperty(Property.Logging.Name, Property.Logging.LibVersion, _libVersion); }
protected override void SetFields(LogCastDocument document) { document.AddProperty("new_line", "\nvalue"); }