Search in sources :

Example 1 with Slf4jLoggingOutputStream

use of com.adaptris.util.stream.Slf4jLoggingOutputStream in project interlok by adaptris.

the class StandardHttpProducer method fail.

private void fail(int responseCode, InputStreamWithEncoding data) throws ProduceException {
    if (log.isTraceEnabled()) {
        try {
            try (OutputStream slf4j = new Slf4jLoggingOutputStream(log, Slf4jLoggingOutputStream.LogLevel.TRACE);
                InputStream in = new BufferedInputStream(data.inputStream);
                PrintStream out = data.encoding == null ? new PrintStream(slf4j) : new PrintStream(slf4j, false, data.encoding)) {
                out.println("Error Data from remote server :");
                IOUtils.copy(in, out);
            }
        } catch (IOException e) {
            log.trace("No Error Data available");
        }
    }
    throw new ProduceException("Failed to send payload, got " + responseCode);
}
Also used : PrintStream(java.io.PrintStream) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) Slf4jLoggingOutputStream(com.adaptris.util.stream.Slf4jLoggingOutputStream) IOException(java.io.IOException) Slf4jLoggingOutputStream(com.adaptris.util.stream.Slf4jLoggingOutputStream) ProduceException(com.adaptris.core.ProduceException)

Example 2 with Slf4jLoggingOutputStream

use of com.adaptris.util.stream.Slf4jLoggingOutputStream in project interlok by adaptris.

the class DebugPoolFactory method create.

@Override
public ComboPooledDataSource create() throws Exception {
    ComboPooledDataSource result = super.create();
    result.setUnreturnedConnectionTimeout(unreturnedConnectionTimeout());
    result.setDebugUnreturnedConnectionStackTraces(debugUnreturnedConnectionStackTraces());
    // lgtm
    result.setLogWriter(new PrintWriter(new Slf4jLoggingOutputStream(logger, "DEBUG"), true));
    return result;
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) PrintWriter(java.io.PrintWriter) Slf4jLoggingOutputStream(com.adaptris.util.stream.Slf4jLoggingOutputStream)

Aggregations

Slf4jLoggingOutputStream (com.adaptris.util.stream.Slf4jLoggingOutputStream)2 ProduceException (com.adaptris.core.ProduceException)1 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1 PrintWriter (java.io.PrintWriter)1