Beispiel #1
0
 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)
 {
     _value = new Dictionary <string, int> {
         { "key1", 23 }, { "key2", 24 }
     };
     document.AddProperty("key", _value);
 }
Beispiel #3
0
 protected virtual void SendTestMessage()
 {
     Sut.Send(() =>
     {
         var doc = new LogCastDocument();
         doc.AddProperty("testKey", "testValue");
         return(doc);
     });
 }
Beispiel #4
0
 protected override void SetFields(LogCastDocument document)
 {
     document.AddProperty("complex_object", new RootObject
     {
         Property1     = "rootvalue",
         Property2     = 23,
         ChildProperty = new ChildObject
         {
             Property3 = "childvalue"
         }
     });
 }
Beispiel #5
0
        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);
            }
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
        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;
        }
Beispiel #9
0
 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("tab", "\tvalue");
 }
Beispiel #11
0
 protected override void SetFields(LogCastDocument document)
 {
     document.AddProperty("key1", "value1");
     document.AddProperty("key2", "value2");
 }
Beispiel #12
0
 protected override void SetFields(LogCastDocument document)
 {
     document.AddProperty("string", (string)null, true);
     document.AddProperty("someKey", "someValue");
     document.AddProperty("int", 0, true);
 }
 protected override void SetFields(LogCastDocument document)
 {
     document.AddProperty("carriage_return", "\rvalue");
 }
 protected override void SetFields(LogCastDocument document)
 {
     document.AddProperty("new_line", "\nvalue");
 }
Beispiel #15
0
 public override void Act()
 {
     _cut.AddProperty("key", 10);
 }
 private void Apply(LogCastDocument document)
 {
     document.AddProperty(Property.AppName, AppName, true);
     document.AddProperty(Property.LoggingFramework, LoggingFramework, true);
 }