| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjcmdline.AbstractHandlerDecorator
jcmdline.LoggerCmdLineHandler
public class LoggerCmdLineHandler
A CmdLineHandler Decorator class that implements a logging option that implements rudimentary support for the java.util.logging package.
 The implemented option is a StringParam whose tag is defined by
 "LoggerCmdLineHandler.logOpt.tag" in the strings.properties file (set
 to "log", in English). The acceptable values for the parameter are set to the
 localized strings that are valid logging levels as defined by the 
 java.util.logging.Level
 class.
 
 Should the user set this option a StreamHandler is added to the root logger
 and the logging level of the root logger and the StreamHandler are set to
 that specified on the command line. It is possible to set a Formatter for the
 log messages (the default is 
 java.util.logging.SimpleFormatter) with
 the setLogFormatter() method. This
 method, if used, must be called prior to any calls to parse().
 
Information on using CmdLineHandlers can be found in the jcmdline User Guide.
CmdLineHandler, 
AbstractHandlerDecorator, 
Logger| Constructor Summary | |
|---|---|
LoggerCmdLineHandler(java.io.OutputStream stream,
                     CmdLineHandler handler)
constructor  | 
|
LoggerCmdLineHandler(java.io.OutputStream stream,
                     java.lang.String cmdName,
                     java.lang.String cmdDesc,
                     java.util.Collection<Parameter<?>> options,
                     java.util.Collection<Parameter<?>> args)
constructor - uses the PosixCmdLineParser to parse the command line  | 
|
LoggerCmdLineHandler(java.io.OutputStream stream,
                     java.lang.String cmdName,
                     java.lang.String cmdDesc,
                     Parameter<?>[] options,
                     Parameter<?>[] args)
constructor - creates a new DefaultCmdLineHandler as its delegate  | 
|
LoggerCmdLineHandler(java.io.OutputStream stream,
                     java.lang.String cmdName,
                     java.lang.String cmdDesc,
                     Parameter<?>[] options,
                     Parameter<?>[] args,
                     CmdLineParser parser)
constructor - creates a new DefaultCmdLineHandler as its delegate  | 
|
| Method Summary | |
|---|---|
 java.util.logging.Formatter | 
getLogFormatter()
Gets the formatter for log messages, defaults to 
 java.util.logging.SimpleFormatter
 . | 
protected  boolean | 
processParsedOptions(boolean parseOk)
Called following the call to parse() of this class's
 contained CmdLineHandler. | 
 void | 
setLogFormatter(java.util.logging.Formatter logFormatter)
Sets the formatter for log messages, defaults to 
 java.util.logging.SimpleFormatter
 . | 
| Methods inherited from class jcmdline.AbstractHandlerDecorator | 
|---|
addArg, addOption, exitUsageError, getArg, getArgs, getCmdDesc, getCmdName, getCustomOptions, getDieOnParseError, getOption, getOptions, getParseError, getParser, getUsage, parse, setArgs, setCmdDesc, setCmdName, setCustomOptions, setDieOnParseError, setOptions, setParseError, setParser | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public LoggerCmdLineHandler(java.io.OutputStream stream,
                            CmdLineHandler handler)
stream - the OutputStream to which to write log messageshandler - the CmdLineHandler to which most functionality will be
            delegated
java.lang.IllegalArgumentException - if stream is null
public LoggerCmdLineHandler(java.io.OutputStream stream,
                            java.lang.String cmdName,
                            java.lang.String cmdDesc,
                            java.util.Collection<Parameter<?>> options,
                            java.util.Collection<Parameter<?>> args)
stream - the OutputStream to which to write log messagescmdName - the name of the command creating this DefaultCmdLineHandlercmdDesc - a short description of the command's purposeoptions - a collection of Parameter objects, describing the command's
            command-line optionsargs - a collection of Parameter objects, describing the command's
            command-line arguments (what is left on the command line after
            all options and their parameters have been processed)
java.lang.IllegalArgumentException - if any of the parameters are not correctly specified.setCmdName(), 
setCmdDesc(), 
setOptions(), 
PosixCmdLineParser
public LoggerCmdLineHandler(java.io.OutputStream stream,
                            java.lang.String cmdName,
                            java.lang.String cmdDesc,
                            Parameter<?>[] options,
                            Parameter<?>[] args)
stream - the OutputStream to which to write log messagescmdName - the name of the commandcmdDesc - a short description of the commandoptions - a collection of Parameter objects, describing the command's
            command-line optionsargs - a collection of Parameter objects, describing the command's
            command-line arguments (what is left on the command line after
            all options and their parameters have been processed)
java.lang.IllegalArgumentException - if any of the parameters are not correctly specified.DefaultCmdLineHandler
public LoggerCmdLineHandler(java.io.OutputStream stream,
                            java.lang.String cmdName,
                            java.lang.String cmdDesc,
                            Parameter<?>[] options,
                            Parameter<?>[] args,
                            CmdLineParser parser)
stream - the OutputStream to which to write log messagescmdName - the name of the commandcmdDesc - a short description of the commandoptions - a collection of Parameter objects, describing the command's
            command-line optionsargs - a collection of Parameter objects, describing the command's
            command-line arguments (what is left on the command line after
            all options and their parameters have been processed)parser - a CmdLineParser to be used to parse the command line
java.lang.IllegalArgumentException - if any of the parameters are not correctly specified.DefaultCmdLineHandler| Method Detail | 
|---|
public java.util.logging.Formatter getLogFormatter()
 java.util.logging.SimpleFormatter
 .
setLogFormatter()public void setLogFormatter(java.util.logging.Formatter logFormatter)
 java.util.logging.SimpleFormatter
 . This method must be called prior to calling parse() -
 calling this method after the command line has been parsed will have no
 effect.
logFormatter - the formatter for log messages
java.lang.IllegalArgumentException - if logFormatter is nullgetLogFormatter()protected boolean processParsedOptions(boolean parseOk)
parse() of this class's
 contained CmdLineHandler. This method only checks for its option if
 parseStatus is true.
 This method adds a ConsoleHandler to the root logger and sets the logging level of the root logger to that specified on the command line.
processParsedOptions in class AbstractHandlerDecoratorparseOk - The result of the parse() call to this class's
            contained CmdLineHandler.
System.exit(0), rather than
         returning, if its option is set. Otherwise,
         parseStatus is returned.
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||