Example #1
0
        private void AppendValueBytes(ByteArray message, LogEventInfo logEvent, EncodingSet encodings)
        {
            var paramValue = paramValuePolicySet.Apply(value.Render(logEvent));
            var valueBytes = encodings.Utf8.GetBytes(paramValue);

            message.Append(valueBytes);
        }
        public void AppendBytes(ByteArray message, string renderedSdId, EncodingSet encodings)
        {
            var sdId      = sdIdPolicySet.Apply(renderedSdId);
            var sdIdBytes = encodings.Ascii.GetBytes(sdId);

            message.Append(sdIdBytes);
        }
Example #3
0
 private void AppendBytes(ByteArray message, LogEventInfo logEvent, string invalidNamesPattern, EncodingSet encodings)
 {
     AppendNameBytes(message, logEvent, invalidNamesPattern, encodings);
     message.Append(EqualBytes);
     message.Append(QuotesBytes);
     AppendValueBytes(message, logEvent, encodings);
     message.Append(QuotesBytes);
 }
Example #4
0
 private void AppendHeaderBytes(ByteArray buffer, string pri, LogEventInfo logEvent, EncodingSet encodings)
 {
     var timestamp = string.Format(CultureInfo.InvariantCulture, TimestampFormat, logEvent.TimeStamp);
     var hostname = hostnamePolicySet.Apply(hostnameLayout.Render(logEvent));
     var appName = appNamePolicySet.Apply(appNameLayout.Render(logEvent));
     var procId = procIdPolicySet.Apply(procIdLayout.Render(logEvent));
     var msgId = msgIdPolicySet.Apply(msgIdLayout.Render(logEvent));
     var header = $"{pri}{version} {timestamp} {hostname} {appName} {procId} {msgId}";
     var headerBytes = encodings.Ascii.GetBytes(header);
     buffer.Append(headerBytes);
 }
Example #5
0
        protected override void PrepareMessage(ByteArray buffer, LogEventInfo logEvent, string pri, string logEntry)
        {
            var encodings = new EncodingSet(!disableBom);

            AppendHeaderBytes(buffer, pri, logEvent, encodings);
            buffer.Append(SpaceBytes);
            AppendStructuredDataBytes(buffer, logEvent, encodings);
            buffer.Append(SpaceBytes);
            AppendMsgBytes(buffer, logEntry, encodings);

            utf8MessagePolicy.Apply(buffer);
        }
Example #6
0
        protected override void PrepareMessage(ByteArray buffer, LogEventInfo logEvent, string pri, string logEntry)
        {
            var encodings = new EncodingSet(!disableBom);

            AppendHeaderBytes(buffer, pri, logEvent, encodings);
            buffer.Append(SpaceBytes);
            AppendStructuredDataBytes(buffer, logEvent, encodings);
            buffer.Append(SpaceBytes);
            AppendMsgBytes(buffer, logEntry, encodings);

            utf8MessagePolicy.Apply(buffer);
        }
        public void AppendBytes(ByteArray message, LogEventInfo logEvent, EncodingSet encodings)
        {
            var sdFromEvtProps = fromEventProperties.Render(logEvent);

            if (!string.IsNullOrEmpty(sdFromEvtProps))
            {
                var sdBytes = encodings.Utf8.GetBytes(sdFromEvtProps);
                message.Append(sdBytes);
                return;
            }

            if (sdElements.Count == 0)
                message.Append(NilValueBytes);
            else
                SdElement.AppendBytes(message, sdElements, logEvent, encodings);
        }
Example #8
0
        public static void AppendBytes(ByteArray message, IEnumerable<SdElement> sdElements, LogEventInfo logEvent, EncodingSet encodings)
        {
            var elements = sdElements
                .Select(x => new { SdId = x.sdId, RenderedSdId = x.sdId.Render(logEvent), SdParams = x.sdParams })
                .ToList();

            InternalLogDuplicatesPolicy.Apply(elements, x => x.RenderedSdId);

            elements
                .ForEach(elem =>
                {
                    message.Append(LeftBracketBytes);
                    elem.SdId.AppendBytes(message, elem.RenderedSdId, encodings);
                    SdParam.AppendBytes(message, elem.SdParams, logEvent, SdIdToInvalidParamNamePattern.Map(elem.RenderedSdId), encodings);
                    message.Append(RightBracketBytes);
                });
        }
Example #9
0
        public void AppendBytes(ByteArray message, LogEventInfo logEvent, EncodingSet encodings)
        {
            var sdFromEvtProps = fromEventProperties.Render(logEvent);

            if (!string.IsNullOrEmpty(sdFromEvtProps))
            {
                var sdBytes = encodings.Utf8.GetBytes(sdFromEvtProps);
                message.Append(sdBytes);
                return;
            }

            if (sdElements.Count == 0)
            {
                message.Append(NilValueBytes);
            }
            else
            {
                SdElement.AppendBytes(message, sdElements, logEvent, encodings);
            }
        }
Example #10
0
        private static void AppendPreambleBytes(ByteArray buffer, EncodingSet encodings)
        {
            var preambleBytes = encodings.Utf8.GetPreamble();

            buffer.Append(preambleBytes);
        }
Example #11
0
        private static void AppendLogEntryBytes(ByteArray buffer, string logEntry, EncodingSet encodings)
        {
            var logEntryBytes = encodings.Utf8.GetBytes(logEntry);

            buffer.Append(logEntryBytes);
        }
Example #12
0
 private void AppendStructuredDataBytes(ByteArray buffer, LogEventInfo logEvent, EncodingSet encodings)
 {
     structuredData.AppendBytes(buffer, logEvent, encodings);
 }
Example #13
0
 private static void AppendMsgBytes(ByteArray buffer, string logEntry, EncodingSet encodings)
 {
     AppendPreambleBytes(buffer, encodings);
     AppendLogEntryBytes(buffer, logEntry, encodings);
 }
Example #14
0
 private void AppendBytes(ByteArray message, LogEventInfo logEvent, string invalidNamesPattern, EncodingSet encodings)
 {
     AppendNameBytes(message, logEvent, invalidNamesPattern, encodings);
     message.Append(EqualBytes);
     message.Append(QuotesBytes);
     AppendValueBytes(message, logEvent, encodings);
     message.Append(QuotesBytes);
 }
Example #15
0
        private void AppendHeaderBytes(ByteArray buffer, string pri, LogEventInfo logEvent, EncodingSet encodings)
        {
            var timestamp   = string.Format(CultureInfo.InvariantCulture, TimestampFormat, logEvent.TimeStamp);
            var hostname    = hostnamePolicySet.Apply(hostnameLayout.Render(logEvent));
            var appName     = appNamePolicySet.Apply(appNameLayout.Render(logEvent));
            var procId      = procIdPolicySet.Apply(procIdLayout.Render(logEvent));
            var msgId       = msgIdPolicySet.Apply(msgIdLayout.Render(logEvent));
            var header      = $"{pri}{version} {timestamp} {hostname} {appName} {procId} {msgId}";
            var headerBytes = encodings.Ascii.GetBytes(header);

            buffer.Append(headerBytes);
        }
Example #16
0
        private void AppendNameBytes(ByteArray message, LogEventInfo logEvent, string invalidNamesPattern, EncodingSet encodings)
        {
            var paramName = paramNamePolicySet.Apply(name.Render(logEvent), invalidNamesPattern);
            var nameBytes = encodings.Ascii.GetBytes(paramName);

            message.Append(nameBytes);
        }
Example #17
0
 private void AppendNameBytes(ByteArray message, LogEventInfo logEvent, string invalidNamesPattern, EncodingSet encodings)
 {
     var paramName = paramNamePolicySet.Apply(name.Render(logEvent), invalidNamesPattern);
     var nameBytes = encodings.Ascii.GetBytes(paramName);
     message.Append(nameBytes);
 }
Example #18
0
 private static void AppendPreambleBytes(ByteArray buffer, EncodingSet encodings)
 {
     var preambleBytes = encodings.Utf8.GetPreamble();
     buffer.Append(preambleBytes);
 }
Example #19
0
 private static void AppendLogEntryBytes(ByteArray buffer, string logEntry, EncodingSet encodings)
 {
     var logEntryBytes = encodings.Utf8.GetBytes(logEntry);
     buffer.Append(logEntryBytes);
 }
        public static void AppendBytes(ByteArray message, IEnumerable <SdElement> sdElements, LogEventInfo logEvent, EncodingSet encodings)
        {
            var elements = sdElements
                           .Select(x => new { SdId = x.sdId, RenderedSdId = x.sdId.Render(logEvent), SdParams = x.sdParams })
                           .ToList();

            InternalLogDuplicatesPolicy.Apply(elements, x => x.RenderedSdId);

            elements
            .ForEach(elem =>
            {
                message.Append(LeftBracketBytes);
                elem.SdId.AppendBytes(message, elem.RenderedSdId, encodings);
                SdParam.AppendBytes(message, elem.SdParams, logEvent, SdIdToInvalidParamNamePattern.Map(elem.RenderedSdId), encodings);
                message.Append(RightBracketBytes);
            });
        }
Example #21
0
 private void AppendStructuredDataBytes(ByteArray buffer, LogEventInfo logEvent, EncodingSet encodings)
 {
     structuredData.AppendBytes(buffer, logEvent, encodings);
 }
Example #22
0
 public static void AppendBytes(ByteArray message, IEnumerable<SdParam> sdParams, LogEventInfo logEvent, string invalidNamesPattern, EncodingSet encodings)
 {
     message.Append(SpaceBytes);
     sdParams.ForEach(sdParam => sdParam.AppendBytes(message, logEvent, invalidNamesPattern, encodings));
 }
Example #23
0
 public static void AppendBytes(ByteArray message, IEnumerable <SdParam> sdParams, LogEventInfo logEvent, string invalidNamesPattern, EncodingSet encodings)
 {
     sdParams.ForEach(sdParam =>
     {
         message.Append(SpaceBytes);
         sdParam.AppendBytes(message, logEvent, invalidNamesPattern, encodings);
     });
 }
Example #24
0
 public void AppendBytes(ByteArray message, string renderedSdId, EncodingSet encodings)
 {
     var sdId = sdIdPolicySet.Apply(renderedSdId);
     var sdIdBytes = encodings.Ascii.GetBytes(sdId);
     message.Append(sdIdBytes);
 }
Example #25
0
 private static void AppendMsgBytes(ByteArray buffer, string logEntry, EncodingSet encodings)
 {
     AppendPreambleBytes(buffer, encodings);
     AppendLogEntryBytes(buffer, logEntry, encodings);
 }
Example #26
0
 private void AppendValueBytes(ByteArray message, LogEventInfo logEvent, EncodingSet encodings)
 {
     var paramValue = paramValuePolicySet.Apply(value.Render(logEvent));
     var valueBytes = encodings.Utf8.GetBytes(paramValue);
     message.Append(valueBytes);
 }