| name | zcl |
| description | Add colored terminal output to Java applications using zcl (Zero-dependency Colour Logger). Use when adding colored console output, terminal logging with colors, ANSI color support, or integrating zcl into a Java project. Triggers on "zcl", "colored output", "colored logging", "terminal colors", "ANSI colors", "console colors", or requests to add color-coded log output to a Java application. |
Add colored terminal output to a Java application using $ARGUMENTS. Apply all rules below.
What is zcl
zcl is a zero-dependency, single-enum Java logging utility using ANSI 24-bit true-colour escape sequences from the Solarized Dark accent palette. zcl is designed as a source-reuse project — the Log.java file is copied directly into your source tree, not consumed as a Maven/Gradle dependency or JAR. This keeps the project free of external dependencies.
Integration
Copy the Log.java enum below into the application's source tree. Adjust the package declaration to match the target package.
import java.io.PrintStream;
public enum Log {
ERROR(Color.RED, System.err),
USER(Color.CYAN, System.out),
INFO(Color.GREEN, System.out),
SYSTEM(Color.BLUE, System.out),
WARNING(Color.YELLOW, System.out),
DEBUG(Color.VIOLET, System.out),
SUCCESS(Color.MAGENTA, System.out);
private PrintStream out;
enum Color {
YELLOW(),
ORANGE(),
RED(),
MAGENTA(),
VIOLET(),
BLUE(),
CYAN(),
GREEN();
String code;
Color(String code) {
.code = code;
}
}
String value;
;
{
.value = (color.code + + RESET);
.out = out;
}
String {
.value.formatted(raw);
}
{
formatted(message);
.out.println(colored);
}
{
Log.DEBUG.out(message);
}
{
Log.ERROR.out(message);
}
{
Log.ERROR.out(message + + e.getMessage());
e.printStackTrace(System.err);
}
{
Log.USER.out(message);
}
{
Log.INFO.out(message);
}
{
Log.SYSTEM.out(message);
}
{
IO.println();
}
{
Log.WARNING.out(message);
}
{
Log.SUCCESS.out(message);
}
{
error(message);
System.exit();
}
}