Search in sources :

Example 11 with FormattedText

use of org.cactoos.text.FormattedText in project cactoos by yegor256.

the class LoggingInputStream method available.

@Override
public int available() throws IOException {
    final int avail = this.origin.available();
    this.logger.log(this.level.value(), new UncheckedText(new FormattedText("There is(are) %d byte(s) available from %s.", avail, this.source)).asString());
    return avail;
}
Also used : UncheckedText(org.cactoos.text.UncheckedText) FormattedText(org.cactoos.text.FormattedText)

Example 12 with FormattedText

use of org.cactoos.text.FormattedText in project cactoos by yegor256.

the class LoggingInputStream method close.

@Override
public void close() throws IOException {
    this.origin.close();
    this.logger.log(this.level.value(), new UncheckedText(new FormattedText("Closed input stream from %s.", this.source)).asString());
}
Also used : UncheckedText(org.cactoos.text.UncheckedText) FormattedText(org.cactoos.text.FormattedText)

Example 13 with FormattedText

use of org.cactoos.text.FormattedText in project cactoos by yegor256.

the class LoggingInputStream method markSupported.

@Override
public boolean markSupported() {
    final boolean supported = this.origin.markSupported();
    final String msg;
    if (supported) {
        msg = "Mark and reset are supported from %s";
    } else {
        msg = "Mark and reset NOT supported from %s";
    }
    this.logger.log(this.level.value(), new UncheckedText(new FormattedText(msg, this.source)).asString());
    return supported;
}
Also used : UncheckedText(org.cactoos.text.UncheckedText) FormattedText(org.cactoos.text.FormattedText)

Example 14 with FormattedText

use of org.cactoos.text.FormattedText in project cactoos by yegor256.

the class LoggingInputStream method mark.

@Override
public void mark(final int limit) {
    this.origin.mark(limit);
    this.logger.log(this.level.value(), new UncheckedText(new FormattedText("Marked position %d from %s.", limit, this.source)).asString());
}
Also used : UncheckedText(org.cactoos.text.UncheckedText) FormattedText(org.cactoos.text.FormattedText)

Example 15 with FormattedText

use of org.cactoos.text.FormattedText in project cactoos by yegor256.

the class LoggingInputStream method skip.

@Override
public long skip(final long num) throws IOException {
    final long skipped = this.origin.skip(num);
    this.logger.log(this.level.value(), new UncheckedText(new FormattedText("Skipped %d byte(s) from %s.", skipped, this.source)).asString());
    return skipped;
}
Also used : UncheckedText(org.cactoos.text.UncheckedText) FormattedText(org.cactoos.text.FormattedText)

Aggregations

FormattedText (org.cactoos.text.FormattedText)15 UncheckedText (org.cactoos.text.UncheckedText)12 Level (java.util.logging.Level)3 Instant (java.time.Instant)2 Text (org.cactoos.Text)2 IterableOf (org.cactoos.iterable.IterableOf)2 Test (org.junit.jupiter.api.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 TextOf (org.cactoos.text.TextOf)1 HasValues (org.llorllale.cactoos.matchers.HasValues)1 Throws (org.llorllale.cactoos.matchers.Throws)1