Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Adjust logging
Browse files Browse the repository at this point in the history
  • Loading branch information
birkland committed Mar 7, 2018
1 parent 39cb06e commit 1424cef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void write(int b) throws IOException {
* Tell the compactor to do JSON-LD compaction when it starts getting input.
*/
public void enableCompaction() {
LOG.info("Enabling compaction");
LOG.debug("Enabling compaction");
this.compactionEnabled = true;
}

Expand All @@ -84,12 +84,12 @@ public void close() throws IOException {

try {
if (compactionEnabled && context != null) {
LOG.info("Doing compaction and writing to {}, which is a {}", super.out, super.out.getClass());
LOG.debug("Doing compaction and writing to {}, which is a {}", super.out, super.out.getClass());
final String compacted = compactor.compact(new String(captured.toByteArray(), UTF_8), context);
LOG.info("Writing compacted jsonld: {}", compacted);
LOG.debug("Writing compacted jsonld: {}", compacted);
super.out.write(compacted.getBytes(UTF_8));
} else {
LOG.info("Not doing compaction");
LOG.debug("Not doing compaction");
}
} catch (final Exception e) {
throw new RuntimeException("Could not compact jsonld", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class CompactionFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {

LOG.warn("Initialized compaction filter");
LOG.info("Initializing compaction filter");

final String context = Optional.ofNullable(filterConfig.getInitParameter("context")).orElse(getValue(
CONTEXT_COMPACTION_URI_PROP));
Expand All @@ -82,9 +82,9 @@ public void init(FilterConfig filterConfig) throws ServletException {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {

LOG.warn("Servicing response");
LOG.debug("Servicing response");

LOG.info("Initial Output Stream: " + response.getOutputStream());
LOG.debug("Initial Output Stream: " + response.getOutputStream());
final CompactionWrapper compactionWrapper = new CompactionWrapper((HttpServletResponse) response, compactor,
defaultContext);
chain.doFilter(request, compactionWrapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public CompactionWrapper(HttpServletResponse response, Compactor compactor, URL

try {
delegate = super.getOutputStream();
LOG.info("Delegate output stream is " + delegate);
LOG.debug("Delegate output stream is " + delegate);
compactingOutputStream = new CompactingOutputStream(delegate, compactor, context);
} catch (final IOException e) {
throw new RuntimeException("Could not open response output stream", e);
Expand Down Expand Up @@ -74,7 +74,7 @@ public boolean isReady() {

@Override
public void close() throws IOException {
LOG.info("Closing compacting output stream");
LOG.debug("Closing compacting output stream");
compactingOutputStream.close();
}
};
Expand All @@ -92,25 +92,15 @@ public PrintWriter getWriter() throws IOException {

@Override
public void addHeader(String name, String value) {
LOG.info("addHeader {} = {}", name, value);

if (!name.equalsIgnoreCase("Length")) {
super.setHeader(name, value);
}

super.addHeader(name, value);
if (name.equalsIgnoreCase("content-type") && value.startsWith(JSON_LD_MEDIA_TYPE)) {
compactingOutputStream.enableCompaction();
}
}

@Override
public void setHeader(String name, String value) {
LOG.info("setHeader {} = {}", name, value);

if (!name.equalsIgnoreCase("Length")) {
super.setHeader(name, value);
}

super.addHeader(name, value);
if (name.equalsIgnoreCase("content-type") && value.startsWith(JSON_LD_MEDIA_TYPE)) {
compactingOutputStream.enableCompaction();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public static Map<String, String> extract(Stream<String> props, String prefix) {
}

public static String getValue(String key) {
LOG.info("Getting value of '{}'", key);
LOG.info(" prop {}: {}", key, System.getProperty(key));
LOG.info(" env {}: {}", key, System.getenv(toEnvName(key)));

return System.getProperty(key, System.getenv(toEnvName(key)));
}

Expand Down

0 comments on commit 1424cef

Please sign in to comment.