CVS: jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends CLIMain.java,1.22,1.23 CLISetup.java,1.10,1.11 Resources.properties,1.4,1.5
Peter Royal <proyal-yCVjj/[email protected]> Wed, 18 Feb 2004 22:00:01 -0600
| Newsgroups | gmane.comp.java.jcontainer.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends
In directory hogshead.codehaus.org:/tmp/cvs-serv8384/loom/engine/src/java/org/jcontainer/loom/frontends
Modified Files:
CLIMain.java CLISetup.java Resources.properties
Log Message:
Add command-line option to log to STDOUT. Very useful for debugging :)
Index: CLIMain.java
===================================================================
RCS file: /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends/CLIMain.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- CLIMain.java 3 Dec 2003 10:44:44 -0000 1.22
+++ CLIMain.java 19 Feb 2004 03:56:21 -0000 1.23
@@ -92,11 +92,14 @@
import java.util.Observable;
import java.util.Observer;
import java.util.Properties;
+
import org.apache.log.Hierarchy;
import org.apache.log.LogTarget;
import org.apache.log.Priority;
import org.apache.log.format.ExtendedPatternFormatter;
import org.apache.log.output.io.FileTarget;
+import org.apache.log.output.io.StreamTarget;
+
import org.codehaus.spice.salt.i18n.ResourceManager;
import org.codehaus.spice.salt.i18n.Resources;
import org.codehaus.spice.salt.lang.ExceptionUtil;
@@ -148,7 +151,7 @@
private Logger m_logger;
private File m_home;
- private FileTarget m_logTarget;
+ private StreamTarget m_logTarget;
/**
* Main entry point.
@@ -172,8 +175,7 @@
}
System.out.println();
- System.out.println(
- ContainerConstants.SOFTWARE + " " + ContainerConstants.VERSION );
+ System.out.println( ContainerConstants.SOFTWARE + " " + ContainerConstants.VERSION );
System.out.println();
final Properties properties = setup.getParameters();
@@ -227,7 +229,7 @@
// If an Observer is present in the data object, then add it as an observer for
// m_observable
- Observer observer = (Observer)data.get( Observer.class.getName() );
+ final Observer observer = (Observer)data.get( Observer.class.getName() );
if( null != observer )
{
addObserver( observer );
@@ -270,18 +272,16 @@
try
{
final String configFilename = properties.getProperty( CONFIGFILE );
- final Configuration original = ConfigurationUtil.buildFromXML(
- new InputSource( configFilename ) );
+ final Configuration original = ConfigurationUtil.buildFromXML( new InputSource( configFilename ) );
final File home = (File)data.get( HOME_DIR );
final Properties params = new Properties();
params.setProperty( "loom.home", home.getAbsolutePath() );
final Configuration root = ConfigUtil.expandValues( original,
params );
final Configuration configuration = root.getChild( "embeddor" );
- final String embeddorClassname = configuration.getAttribute(
- "class" );
+ final String embeddorClassname = configuration.getAttribute( "class" );
m_embeddor =
- (Embeddor)Class.forName( embeddorClassname ).newInstance();
+ (Embeddor)Class.forName( embeddorClassname ).newInstance();
m_logger = createLogger( properties );
ContainerUtil.enableLogging( m_embeddor, m_logger );
@@ -312,10 +312,9 @@
}
/**
- * Uses {@link org.apache.log.Hierarchy} to create a new logger using "Loom"
- * as its category, DEBUG as its priority and the log-destination from
- * Parameters as its destination. TODO: allow configurable priorities and
- * multiple logtargets.
+ * Uses {@link org.apache.log.Hierarchy} to create a new logger using "Loom" as its category, DEBUG as its priority
+ * and the log-destination from Parameters as its destination. TODO: allow configurable priorities and multiple
+ * logtargets.
*/
private Logger createLogger( final Properties properties )
throws Exception
@@ -325,10 +324,17 @@
m_home + DEFAULT_LOG_FILE );
final String logPriority =
properties.getProperty( "log-priority", "INFO" );
- final ExtendedPatternFormatter formatter = new ExtendedPatternFormatter(
- DEFAULT_FORMAT );
- final File file = new File( logDestination );
- m_logTarget = new FileTarget( file, false, formatter );
+ final ExtendedPatternFormatter formatter = new ExtendedPatternFormatter( DEFAULT_FORMAT );
+
+ if( "true".equals( properties.getProperty( "log-stdout", "false" ) ) )
+ {
+ m_logTarget = new StreamTarget( System.out, formatter );
+ }
+ else
+ {
+ final File file = new File( logDestination );
+ m_logTarget = new FileTarget( file, false, formatter );
+ }
//Create an anonymous hierarchy so no other
//components can get access to logging hierarchy
@@ -343,8 +349,7 @@
/**
* Shut the embeddor down.
*
- * Note must be public so that the Frontend can shut it down via
- * reflection.
+ * Note must be public so that the Frontend can shut it down via reflection.
*/
public synchronized void shutdown()
{
@@ -393,8 +398,8 @@
if( null != m_logger )
{
trace =
- ExceptionUtil.prettyPrintStackTrace( throwable,
- "org.jcontainer.loom.components" );
+ ExceptionUtil.prettyPrintStackTrace( throwable,
+ "org.jcontainer.loom.components" );
m_logger.error( throwable.getMessage(), throwable );
}
else
Index: CLISetup.java
===================================================================
RCS file: /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends/CLISetup.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- CLISetup.java 3 Dec 2003 02:54:43 -0000 1.10
+++ CLISetup.java 19 Feb 2004 03:56:21 -0000 1.11
@@ -88,6 +88,7 @@
import java.util.List;
import java.util.Properties;
+
import org.codehaus.spice.salt.i18n.ResourceManager;
import org.codehaus.spice.salt.i18n.Resources;
import org.realityforge.cli.CLArgsParser;
@@ -111,6 +112,7 @@
private static final int LOG_FILE_OPT = 'l';
private static final int PERSISTENT_OPT = 'p';
private static final int CONFIGFILE_OPT = 'f';
+ private static final int STDOUT_OPT = 's';
///Parameters created by parsing CLI options
private final Properties m_parameters = new Properties();
@@ -129,8 +131,7 @@
private void usage( final CLOptionDescriptor[] options )
{
System.err.println( m_command );
- System.err.println(
- "\t" + REZ.getString( "cli.desc.available.header" ) );
+ System.err.println( "\t" + REZ.getString( "cli.desc.available.header" ) );
System.err.println( CLUtil.describeOptions( options ) );
}
@@ -139,32 +140,37 @@
*/
private CLOptionDescriptor[] createCLOptions()
{
- final CLOptionDescriptor options[] = new CLOptionDescriptor[ 5 ];
- options[ 0 ] =
- new CLOptionDescriptor( "help",
- CLOptionDescriptor.ARGUMENT_DISALLOWED,
- HELP_OPT,
- REZ.getString( "cli.opt.help.desc" ) );
- options[ 1 ] =
- new CLOptionDescriptor( "log-file",
- CLOptionDescriptor.ARGUMENT_REQUIRED,
- LOG_FILE_OPT,
- REZ.getString( "cli.opt.log-file.desc" ) );
- options[ 2 ] =
- new CLOptionDescriptor( "debug-init",
- CLOptionDescriptor.ARGUMENT_DISALLOWED,
- DEBUG_LOG_OPT,
- REZ.getString( "cli.opt.debug-init.desc" ) );
- options[ 3 ] =
- new CLOptionDescriptor( "persistent",
- CLOptionDescriptor.ARGUMENT_DISALLOWED,
- PERSISTENT_OPT,
- REZ.getString( "cli.opt.persistent.desc" ) );
- options[ 4 ] =
- new CLOptionDescriptor( "configfile",
- CLOptionDescriptor.ARGUMENT_REQUIRED,
- CONFIGFILE_OPT,
- REZ.getString( "cli.opt.configfile.desc" ) );
+ final CLOptionDescriptor options[] = new CLOptionDescriptor[6];
+ options[0] =
+ new CLOptionDescriptor( "help",
+ CLOptionDescriptor.ARGUMENT_DISALLOWED,
+ HELP_OPT,
+ REZ.getString( "cli.opt.help.desc" ) );
+ options[1] =
+ new CLOptionDescriptor( "log-file",
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ LOG_FILE_OPT,
+ REZ.getString( "cli.opt.log-file.desc" ) );
+ options[2] =
+ new CLOptionDescriptor( "debug-init",
+ CLOptionDescriptor.ARGUMENT_DISALLOWED,
+ DEBUG_LOG_OPT,
+ REZ.getString( "cli.opt.debug-init.desc" ) );
+ options[3] =
+ new CLOptionDescriptor( "persistent",
+ CLOptionDescriptor.ARGUMENT_DISALLOWED,
+ PERSISTENT_OPT,
+ REZ.getString( "cli.opt.persistent.desc" ) );
+ options[4] =
+ new CLOptionDescriptor( "configfile",
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ CONFIGFILE_OPT,
+ REZ.getString( "cli.opt.configfile.desc" ) );
+ options[5] =
+ new CLOptionDescriptor( "std-out",
+ CLOptionDescriptor.ARGUMENT_DISALLOWED,
+ STDOUT_OPT,
+ REZ.getString( "cli.opt.configfile.stdout" ) );
return options;
}
@@ -224,6 +230,10 @@
case CONFIGFILE_OPT:
m_parameters.setProperty( CLIMain.CONFIGFILE,
option.getArgument() );
+ break;
+
+ case STDOUT_OPT:
+ m_parameters.setProperty( "log-stdout", "true" );
break;
}
}
Index: Resources.properties
===================================================================
RCS file: /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends/Resources.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Resources.properties 3 Nov 2003 05:52:13 -0000 1.4
+++ Resources.properties 19 Feb 2004 03:56:21 -0000 1.5
@@ -3,6 +3,7 @@
cli.opt.debug-init.desc=Use this option to specify enable debug initialisation logs.
cli.opt.persistent.desc=If specified the Embeddor will persist even after all applications have been removed from the kernel.
cli.opt.configfile.desc=If specified Loom will use this configfile.
+cli.opt.configfile.stdout=If specified Loom will log to STDOUT rather than log file
cli.desc.available.header=Available options: