Skip to content
Jordan Samhi edited this page Aug 22, 2023 · 1 revision

Writer ✍️

Writer is a class provided in the package com.jordansamhi.androspecter.printers. It offers methods for printing various types of messages to the console, each with different prefix indicators.

Table of Contents

Overview

Writer can print messages with different types of prefixes, making it easier to distinguish between error, success, warning, and informational messages.

Instance Retrieval

v()

Returns the single instance of the Writer class. If no instance exists, it's created.

Error Printing

perror(String s)

Prints an error message to the console, with a prefix 'x' indicating an error.

Success Printing

psuccess(String s)

Prints a success message to the console, with a prefix '✓' indicating success.

Warning Printing

pwarning(String s)

Prints a warning message to the console, with a prefix '!' indicating a warning.

Information Printing

pinfo(String s)

Prints an informational message to the console, with a prefix '*' indicating information.

Examples

Example 1: Printing an Error Message

Writer.v().perror("An error occurred.");

Example 2: Printing a Success Message

Writer.v().psuccess("Operation completed successfully.");

Example 3: Printing a Warning Message

Writer.v().pwarning("Low disk space.");

Example 4: Printing an Informational Message

Writer.v().pinfo("File saved.");

These examples demonstrate how to use the Writer class to print various types of messages to the console with distinct prefix indicators.