From e991a8f1dce8c255836ae40ae522f7f8589cea89 Mon Sep 17 00:00:00 2001 From: Ben Alman Date: Fri, 23 Mar 2012 07:51:38 -0400 Subject: [PATCH] More grunt.log documentation. --- docs/api_log.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/api_log.md b/docs/api_log.md index 0a695b396..770a87608 100644 --- a/docs/api_log.md +++ b/docs/api_log.md @@ -77,7 +77,8 @@ This object contains all methods of `grunt.log` but only logs if the `--verbose` grunt.verbose.or ``` -## Utility +## Utility Methods +These methods don't actually log, they just return strings that can be used in other methods. ### grunt.log.wordlist Returns a comma-separated list of `arr` array items. @@ -86,6 +87,28 @@ Returns a comma-separated list of `arr` array items. grunt.log.wordlist(arr) ``` +### grunt.log.uncolor +Removes all color information from a string, making it suitable for testing `.length` or perhaps logging to a file. + +```javascript +grunt.log.uncolor(str) +``` + +### grunt.log.wraptext +Wrap `text` string to `width` characters with `\n`, ensuring that words are not split in the middle unless absolutely necessary. + +```javascript +grunt.log.wraptext(width, text) +``` + +### grunt.log.table +Wrap `texts` array of strings to columns `widths` characters wide. A wrapper for the `grunt.log.wraptext` method that can be used to generate output in columns. + +```javascript +grunt.log.table(widths, texts) +``` + + ## An Example A common pattern is to only log when in `--verbose` mode OR if an error occurs, like so: