Last updated by antony 7 months ago
Enhances the grails console output for better visibility.
RationaleThis plugin was born as a result of seeing too many of my colleagues typing:
println ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ${myValue}" UsageUsage is designed to be as simple and as unintrusive as possible. Essentially this plugin takes the bold step of overriding the 'println' method on the Object class'. What this means is that any time you type:
Your println will come up in the console in bold, colour, flashing, or whatever custom values you have put into the configuration (see below)
If you want to use a custom set of colours for a particular println, you can use up to three:
println ANSICode.ITALIC_ON, ANSICode.FOREGROUND_RED, ANSICode.BACKGROUND_YELLOW, "my text"
If you want any more control, see 'advanced usage below'.
ConfigurationConfiguration is automatic, if you like your printlns in bold aqua coloured text. If not, it's simple to override:
console {
colours {
normal = [ANSICode.FOREGROUND_RED, ANSICode.BOLD_ON]
}
}Where the list assigned to the 'normal' attribute can by any number of values from the provided
ANSICode enum. The ANSI escape sequence is automatically reset after each println.
LimitationsThis plugin requires that you have an ANSI capable terminal. As with most things that are great about computing, this means that this plugin will not work on windows, and will likely print a number of ugly ANSI escape sequences around your printlns!
Advanced UsageYou can format any text using ANSI by manually invoking the
ANSISequence class' .format method. This is probably most useful in Grails event scripts:
new ANSISequence(ANSICode.FOREGROUND_YELLOW, ANSICode.BACKGROUND_MAGENTA).format('test message')