Diogo Nunes Software

JCDP | ...

JCDP

Download

License

Documentation

Examples + Screenshots

Support

Changelog

FAQ

jcdp logo

JCDP

What is JCDP?

JCDP - Java Colored Debug Printer - is a Java library that mainly offers you a convenient way to print debug messages or colored messages on a terminal.

It all started when I needed to create an application with multiple levels of debug. The solution was an object (a Printer) with a maximum level of debug. Every debug message delivered to it had a level. If the Printer had an equal or greater level, the debug message would be printed. This allows you to place debug messages with different levels along the code. Then, when initiating the app, you choose a maximum level of debug and only the debug messages with an equal or lower level will be displayed. Even better you can change that maximum level dynamically.

To enhance the usefulness of this library I decided to add colored messages, which turned out to be pretty tricky. By abstracting the Ansi Escape Codes, printing a colored message became as easy as  print("message", Attribute.BOLD, FColor.BLUE, BColor.YELLOW);

Main features:

  • Print colored messages on a UNIX terminal or a WINDOWS command console.
  • Place inline debug messages with different levels of debug and let the Printer do the work of checking whether that message should be printed or not.
  • Adaptable. Change the attributes of a Printer dynamically, anytime you want.
  • Scalable. Combine multiple printers to have normal, error and debug messages displaying in several colors.
  • Extensible. You can write your own implementations of Printers - as long as they implement the same interfaces - and use them dynamically.
  • Easy to use. This library was developed with the worry to minimize the number of classes (maximum two) with which the user has to interact. To achieve it, several abstractions were used to hide the concrete implementation.

Download

JCDP comes in two flavors: a Unix-only version and a cross-platform (both Unix and Windows) version. The Windows version is larger because it uses an external library called JAnsi, which is also included in the download file. This happens because Windows' command console doesn't interpret Ansi Escape Codes, which are the basis to print colored messages, so another layer of software is needed to solve this "limitation". Unix's terminal interpret these codes before displaying them so there's no need to use external libraries. Both versions were tested under Unix (@Ubuntu-x86) and Windows (@Windows7-x86).

Download JCDP (v1.25 beta*) for WIN/NIX systems
Download JCDP (v1.25 beta*) for NIX systems only | Download JCDP's source code

*why the beta: it's like "ready for the public, but were continuously going to be tinkering with it" or "go ahead, use it, but go easy on us if something collapses into itself and becomes a black hole". [source]

License

JCDP  Copyright (C) 2011  Diogo Nunes
This program is free software under the terms of the GNU General Public License version 3 and it comes with ABSOLUTELY NO WARRANTY. Check JCDP's full license here

Documentation

JCDP's simplified UML
Check JCDP's javadoc here

Examples

This is a screenshot of the example code shown below, running at Ubuntu 11.04 (x86).

Screenshot of example execution at unix

This is a screenshot of the same example, running at Windows 7 (x86).
Note that for Windows "reversing" the colors is not quite what we would expect.

Screenshot of example execution at windows

You can have a look at the code that produces the outputs shown above. It should give you an overview of the main use cases of this library.

Support

As you read above, this is beta and libre software. If you found any bugs or have any sugestion feel free to contact me info[]diogonunes.com

Changelog

    For future releases:
  • Create a FilePrinter, an implementation that prints to a file rather than a terminal.
    1.25:
  • Refactored the interaction between user and the library
  • Constructors modified to use Builder Pattern to create objects, i.e. printers.
  • Colored Printer interface
  • Colored Printer
  • Packages organized
    1.15:
  • Printer interface
  • Terminal Printer

FAQ

-----

© Diogo Nunes Software 2011