Skip to content
Jordan Samhi edited this page Oct 25, 2026 · 3 revisions

Writer

com.jordansamhi.androspecter.printers.Writer is a compatibility facade over SLF4J. In the 2.0.0 API, it no longer prints directly to the console or adds symbol prefixes. The calling application supplies a logging provider and configures levels and destinations.

API

Method SLF4J level
perror(message) ERROR
pwarning(message) WARN
pinfo(message) INFO
psuccess(message) INFO

Messages are passed unchanged. perror does not throw or exit the JVM; it only emits a log event subject to the provider's configuration.

Writer.v() returns the shared facade using the logger named after Writer. new Writer() uses that same logger name. new Writer(logger) accepts an application-selected SLF4J logger and rejects null.

Use an application logger

This complete utility class lets the calling application decide when an operation is complete:

import com.jordansamhi.androspecter.printers.Writer;
import org.slf4j.LoggerFactory;

public final class LoggingExample {
    private static final Writer LOG =
        new Writer(LoggerFactory.getLogger(LoggingExample.class));

    /**
     * Reports a caller-provided count through the configured SLF4J provider.
     * @param findings number of findings returned by the caller's analysis
     */
    public static void report(int findings) {
        LOG.pinfo("Analysis returned " + findings + " findings");
    }
}

For new application code, using org.slf4j.Logger directly also supports parameterized messages and exception arguments. Writer provides only the four single-string methods above.

AndroSpecter supplies slf4j-api 2.0.17, not a runtime provider. Add one provider such as org.slf4j:slf4j-simple:2.0.17 with runtime scope in the calling application. See Cancellation and logging for the dependency declaration and the distinction between analysis logs and injected Android logging probes.

Clone this wiki locally