Skip to content
forked from dialex/JColor

An easy syntax to print messages with a colored font/background. Also includes ∞ levels of debug logging.

License

Notifications You must be signed in to change notification settings

jonreding2010/JCDP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis Build Status Codacy Badge Version License Donate

Java Colored Debug Printer (JCDP) offers you an easy syntax to print messages with a colored font or background on a terminal. It also provides custom levels of debug logging.

Screenshots

Ubuntu screenshot

Running on Ubuntu

MacIterm screenshot

Running on MacOS X Yosemite (iTerm)

Win8cmd screenshot

Running on Windows 8.1 (cmd)

Example

The screenshots above were produced by running this example code:

// =============================
// Example of a terminal Printer
// =============================

Printer p = new Printer.Builder(Types.TERM).build();
p.println(p);
p.println("This is a normal message.");
p.errorPrintln("This is an error message.");
p.debugPrintln("This debug message is always printed.");
p = new Printer.Builder(Types.TERM).level(1).timestamping(false).build();
p.println(p);
p.debugPrintln("This is printed because its level is <= 1", 1);
p.debugPrintln("This isn't printed because its level is > 1", 2);
p.setLevel(2);
p.debugPrintln("Now this is printed because its level is <= 2", 2);

// =======================================================
// Example of a Colored terminal Printer (WINDOWS or UNIX)
// =======================================================

ColoredPrinter cp = new ColoredPrinter.Builder(1, false)
                        .foreground(FColor.WHITE).background(BColor.BLUE)   //setting format
                        .build();

//printing according to that format
cp.println(cp);
cp.setAttribute(Attribute.REVERSE);
cp.println("This is a normal message (with format reversed).");

//resetting the terminal to its default colors
cp.clear();
cp.print(cp.getDateFormatted(), Attribute.NONE, FColor.CYAN, BColor.BLACK);
cp.debugPrintln(" This debug message is always printed.");
cp.clear();
cp.print("This example used JCDP 1.25   ");

//temporarily overriding that format
cp.print("\tMADE ", Attribute.BOLD, FColor.YELLOW, BColor.GREEN);
cp.print("IN PORTUGAL\t\n", Attribute.BOLD, FColor.YELLOW, BColor.RED);
cp.println("I hope you find it useful ;)");

cp.clear(); //don't forget to clear the terminal's format before exiting

Build tools

You can import this library through Maven or Gradle, just pick a version.

Documentation

Javadoc

Changelog

License

JCDP Copyright (C) 2011-* Diogo Nunes This program is licensed under the terms of the MIT License and it comes with ABSOLUTELY NO WARRANTY. For more details check LICENSE.

Credits

A big thanks to all contributors, specially @xafero who maven-ized this whole project.

About

An easy syntax to print messages with a colored font/background. Also includes ∞ levels of debug logging.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%