blob: a9b8a9a67e26358fa1acc466629cc2a48972d584 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.processing.processors;
import com.yahoo.processing.Processor;
import com.yahoo.processing.Request;
import com.yahoo.processing.Response;
import com.yahoo.processing.execution.Execution;
import java.util.Map;
/**
* A processor which adds the current content of the Request.properties() to
* the trace before calling the next processor, if traceLevel is 4 or more.
*
* @author bratseth
* @since 5.1.17
*/
public class RequestPropertyTracer extends Processor {
@Override
public Response process(Request request, Execution execution) {
if (execution.trace().getTraceLevel()<4) return execution.process(request);
StringBuilder b = new StringBuilder("{");
for (Map.Entry<String,Object> property : request.properties().listProperties().entrySet())
b.append(property.getKey()).append(": '").append(property.getValue()).append("',");
b.setLength(b.length()-1); // remove last comma
b.append("}");
execution.trace().trace(b.toString(),4);
return execution.process(request);
}
}
|