Groovy Documentation

grails.build.logging
[Java] Class GrailsConsole

java.lang.Object
  grails.build.logging.GrailsConsole

public class GrailsConsole
extends java.lang.Object

Utility class for delivering console output in a nicely formatted way.

Authors:
Graeme Rocher
Since:
2.0


Field Summary
static java.lang.String CATEGORY_SEPARATOR

static java.lang.String ENABLE_INTERACTIVE

static java.lang.String ENABLE_TERMINAL

static java.lang.String ERROR

static java.lang.String HISTORYFILE

static java.lang.String LINE_SEPARATOR

static java.lang.String PROMPT

static java.lang.Character SECURE_MASK_CHAR

static java.lang.String SPACE

static java.lang.String STACKTRACE_FILTERED_MESSAGE

static java.lang.String STACKTRACE_MESSAGE

static java.lang.String WARNING

 
Constructor Summary
protected GrailsConsole()

 
Method Summary
void addStatus(java.lang.String msg)

Keeps doesn't replace the status message

protected java.io.OutputStream ansiWrap(java.io.OutputStream out)

Hook method that allows controlling whether or not output streams should be wrapped by AnsiConsole.wrapOutputStream.

void append(java.lang.String msg)

protected jline.console.ConsoleReader createConsoleReader()

static GrailsConsole createInstance()

protected jline.Terminal createTerminal()

Creates the instance of Terminal used directly in GrailsConsole.

void echoStatus()

Replays the last status message

void error(java.lang.String msg)

Prints an error message

void error(java.lang.String msg, java.lang.Throwable error)

void error(java.lang.Throwable error)

Use to log an error

void error(java.lang.String label, java.lang.String message)

void flush()

java.util.Stack getCategory()

java.io.PrintStream getErr()

java.io.InputStream getInput()

static GrailsConsole getInstance()

java.lang.String getLastMessage()

@return The last message logged

java.io.PrintStream getOut()

jline.console.ConsoleReader getReader()

jline.Terminal getTerminal()

void indicateProgress()

void indicateProgress(int number, int total)

Indicate progress for a number and total

void indicateProgress(int number)

Indicates progress by number

void indicateProgressPercentage(long number, long total)

Indicates progress as a percentage for the given number and total

void info(java.lang.String msg)

Synonym for #log

boolean isAnsiEnabled()

boolean isStacktrace()

boolean isVerbose()

boolean isWindows()

void log(java.lang.String msg)

Logs a message below the current status message

protected jline.console.history.History prepareHistory()

Prepares a history file to be used by the ConsoleReader.

java.lang.String secureUserInput(java.lang.String msg)

void setAnsiEnabled(boolean ansiEnabled)

void setErr(java.io.PrintStream err)

static void setInstance(GrailsConsole newConsole)

void setLastMessage(java.lang.String lastMessage)

void setOut(java.io.PrintStream out)

void setStacktrace(boolean stacktrace)

@param stacktrace Sets whether to show stack traces on errors

void setVerbose(boolean verbose)

@param verbose Sets whether verbose output should be used

java.lang.String showPrompt()

Shows the prompt to request user input

void updateStatus(java.lang.String msg)

Updates the current state message

java.lang.String userInput(java.lang.String msg)

Replacement for AntBuilder.input() to eliminate dependency of GrailsScriptRunner on the Ant libraries.

java.lang.String userInput(java.lang.String message, java.util.List validResponses)

java.lang.String userInput(java.lang.String message, java.lang.String[] validResponses)

void verbose(java.lang.String msg)

void warn(java.lang.String msg)

void warning(java.lang.String msg)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

CATEGORY_SEPARATOR

public static final java.lang.String CATEGORY_SEPARATOR


ENABLE_INTERACTIVE

public static final java.lang.String ENABLE_INTERACTIVE


ENABLE_TERMINAL

public static final java.lang.String ENABLE_TERMINAL


ERROR

public static final java.lang.String ERROR


HISTORYFILE

public static final java.lang.String HISTORYFILE


LINE_SEPARATOR

public static final java.lang.String LINE_SEPARATOR


PROMPT

public static final java.lang.String PROMPT


SECURE_MASK_CHAR

public static final java.lang.Character SECURE_MASK_CHAR


SPACE

public static final java.lang.String SPACE


STACKTRACE_FILTERED_MESSAGE

public static final java.lang.String STACKTRACE_FILTERED_MESSAGE


STACKTRACE_MESSAGE

public static final java.lang.String STACKTRACE_MESSAGE


WARNING

public static final java.lang.String WARNING


 
Constructor Detail

GrailsConsole

protected GrailsConsole()


 
Method Detail

addStatus

public void addStatus(java.lang.String msg)
Keeps doesn't replace the status message
Parameters:
msg - The message


ansiWrap

protected java.io.OutputStream ansiWrap(java.io.OutputStream out)
Hook method that allows controlling whether or not output streams should be wrapped by AnsiConsole.wrapOutputStream. Unfortunately, Eclipse consoles will look to the AnsiWrap like they do not understand ansi, even if we were to implement support in Eclipse to' handle it and the wrapped stream will not pass the ansi chars on to Eclipse).


append

public void append(java.lang.String msg)


createConsoleReader

protected jline.console.ConsoleReader createConsoleReader()


createInstance

public static GrailsConsole createInstance()


createTerminal

protected jline.Terminal createTerminal()
Creates the instance of Terminal used directly in GrailsConsole. Note that there is also another terminal instance created implicitly inside of ConsoleReader. That instance is controlled by the jline.terminal system property.


echoStatus

public void echoStatus()
Replays the last status message


error

public void error(java.lang.String msg)
Prints an error message
Parameters:
msg - The error message


error

public void error(java.lang.String msg, java.lang.Throwable error)


error

public void error(java.lang.Throwable error)
Use to log an error
Parameters:
error - The error


error

public void error(java.lang.String label, java.lang.String message)


flush

public void flush()


getCategory

public java.util.Stack getCategory()


getErr

public java.io.PrintStream getErr()


getInput

public java.io.InputStream getInput()


getInstance

public static GrailsConsole getInstance()


getLastMessage

public java.lang.String getLastMessage()
Returns:
The last message logged


getOut

public java.io.PrintStream getOut()


getReader

public jline.console.ConsoleReader getReader()


getTerminal

public jline.Terminal getTerminal()


indicateProgress

public void indicateProgress()


indicateProgress

public void indicateProgress(int number, int total)
Indicate progress for a number and total
Parameters:
number - The current number
total - The total number


indicateProgress

public void indicateProgress(int number)
Indicates progress by number
Parameters:
number - The number


indicateProgressPercentage

public void indicateProgressPercentage(long number, long total)
Indicates progress as a percentage for the given number and total
Parameters:
number - The number
total - The total


info

public void info(java.lang.String msg)
Synonym for #log
Parameters:
msg - The message to log


isAnsiEnabled

public boolean isAnsiEnabled()


isStacktrace

public boolean isStacktrace()


isVerbose

public boolean isVerbose()


isWindows

public boolean isWindows()


log

public void log(java.lang.String msg)
Logs a message below the current status message
Parameters:
msg - The message to log


prepareHistory

protected jline.console.history.History prepareHistory()
Prepares a history file to be used by the ConsoleReader. This file will live in the home directory of the user.


secureUserInput

public java.lang.String secureUserInput(java.lang.String msg)


setAnsiEnabled

public void setAnsiEnabled(boolean ansiEnabled)


setErr

public void setErr(java.io.PrintStream err)


setInstance

public static void setInstance(GrailsConsole newConsole)


setLastMessage

public void setLastMessage(java.lang.String lastMessage)


setOut

public void setOut(java.io.PrintStream out)


setStacktrace

public void setStacktrace(boolean stacktrace)
Parameters:
stacktrace - Sets whether to show stack traces on errors


setVerbose

public void setVerbose(boolean verbose)
Parameters:
verbose - Sets whether verbose output should be used


showPrompt

public java.lang.String showPrompt()
Shows the prompt to request user input
Returns:
The user input prompt


updateStatus

public void updateStatus(java.lang.String msg)
Updates the current state message
Parameters:
msg - The message


userInput

public java.lang.String userInput(java.lang.String msg)
Replacement for AntBuilder.input() to eliminate dependency of GrailsScriptRunner on the Ant libraries. Prints a message and returns whatever the user enters (once they press <return>).
Parameters:
msg - The message/question to display.
Returns:
The line of text entered by the user. May be a blank string.


userInput

public java.lang.String userInput(java.lang.String message, java.util.List validResponses)


userInput

public java.lang.String userInput(java.lang.String message, java.lang.String[] validResponses)


verbose

public void verbose(java.lang.String msg)


warn

public void warn(java.lang.String msg)


warning

public void warning(java.lang.String msg)


 

Groovy Documentation