1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.access.common.pattern;
15
16 import ch.qos.logback.access.common.spi.IAccessEvent;
17 import ch.qos.logback.core.Context;
18 import ch.qos.logback.core.pattern.Converter;
19 import ch.qos.logback.core.pattern.ConverterUtil;
20 import ch.qos.logback.core.pattern.PostCompileProcessor;
21
22 public class EnsureLineSeparation implements PostCompileProcessor<IAccessEvent> {
23
24
25
26
27
28 @Override
29 public void process(Context context, Converter<IAccessEvent> head) {
30 if (head == null)
31 throw new IllegalArgumentException("Empty converter chain");
32
33
34 Converter<IAccessEvent> tail = ConverterUtil.findTail(head);
35 Converter<IAccessEvent> newLineConverter = new ch.qos.logback.access.common.pattern.LineSeparatorConverter();
36 if (!(tail instanceof ch.qos.logback.access.common.pattern.LineSeparatorConverter)) {
37 tail.setNext(newLineConverter);
38 }
39 }
40 }