mcconnell 2004/01/26 09:36:16
Modified: merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit
ConfigurationParameter.java
DefaultLoggingCriteria.java
DefaultLoggingFactory.java
DefaultLoggingManager.java Resources.properties
merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory
DatagramTargetFactory.java FileTargetFactory.java
FormatterFactory.java SocketTargetFactory.java
merlin/logging/logkit/test project.xml
merlin/logging/logkit/test/conf logging.xml
merlin/logging/logkit/test/src/test/org/apache/avalon/logging/logkit/test
DefaultLoggingManagerTestCase.java
Added:
merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory
Resources.properties
Log:
1. improve logging configuration layout
2. addition of complete i18n coverage
Revision Changes Path
1.2 +18 -10
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/ConfigurationParameter.java
Index: ConfigurationParameter.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/ConfigurationParameter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConfigurationParameter.java 24 Jan 2004 23:25:33 -0000 1.1
+++ ConfigurationParameter.java 26 Jan 2004 17:36:16 -0000 1.2
@@ -29,6 +29,8 @@
import org.apache.avalon.util.criteria.Parameter;
import org.apache.avalon.util.criteria.CriteriaException;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
/**
* A parameter descriptor that supports transformation of a
@@ -46,6 +48,9 @@
private static final DefaultConfigurationBuilder BUILDER =
new DefaultConfigurationBuilder();
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( ConfigurationParameter.class );
+
//--------------------------------------------------------------
// constructors
//--------------------------------------------------------------
@@ -92,7 +97,9 @@
if( !file.exists() )
{
final String error =
- "Configuration file not found: " + file;
+ REZ.getString(
+ "parameter.configuration.fnf.error",
+ file.toString() );
throw new CriteriaException( error );
}
@@ -104,8 +111,9 @@
catch( Throwable e )
{
final String error =
- "File to configuration convertion error from source: "
- + file;
+ REZ.getString(
+ "parameter.configuration.file.error",
+ file.toString() );
throw new CriteriaException( error );
}
}
@@ -119,19 +127,19 @@
catch( Throwable e )
{
final String error =
- "URL to configuration convertion error from source: "
- + value;
+ REZ.getString(
+ "parameter.configuration.url.error",
+ value.toString() );
throw new CriteriaException( error );
}
}
else
{
final String error =
- "Don't know how to transform an instance of ["
- + value.getClass().getName()
- + " to a Configuration.";
+ REZ.getString(
+ "parameter.unknown",
+ value.getClass().getName(), Configuration.class.getName() );
throw new CriteriaException( error );
}
}
-
}
1.2 +17 -12
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/DefaultLoggingCriteria.java
Index: DefaultLoggingCriteria.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/DefaultLoggingCriteria.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultLoggingCriteria.java 24 Jan 2004 23:25:33 -0000 1.1
+++ DefaultLoggingCriteria.java 26 Jan 2004 17:36:16 -0000 1.2
@@ -39,6 +39,8 @@
import org.apache.avalon.util.criteria.Criteria;
import org.apache.avalon.util.criteria.Parameter;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.excalibur.configuration.ConfigurationUtil;
/**
@@ -61,6 +63,9 @@
private static final String LOGGING_PROPERTIES = "avalon.logging.properties";
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultLoggingCriteria.class );
+
/**
* The factory parameters template.
* @return the set of parameters constraining the criteria
@@ -75,10 +80,9 @@
LOGGING_BASEDIR_KEY,
File.class,
BASEDIR ),
- new Parameter(
+ new LoggerParameter(
LOGGING_BOOTSTRAP_KEY,
- Logger.class,
- new ConsoleLogger( ConsoleLogger.LEVEL_INFO ) ),
+ new ConsoleLogger( ConsoleLogger.LEVEL_WARN ) ),
new Parameter(
FACTORY_ARTIFACT_KEY,
String.class,
@@ -216,8 +220,10 @@
}
catch( Throwable e )
{
- final String error =
- "Internal error while attempting to resolve default implementation
artifact.";
+ final String error =
+ REZ.getString(
+ "criteria.artifact.default.error",
+ BASEDIR, LOGGING_PROPERTIES, IMPLEMENTATION_KEY );
throw new LoggingRuntimeException( error, e );
}
}
@@ -230,12 +236,11 @@
}
catch( Throwable e )
{
- final String error =
- "Unable to resolve cononical representation of: "
- + file
- + " due to: "
- + e.getMessage();
- throw new RuntimeException( error );
+ final String error =
+ REZ.getString(
+ "criteria.artifact.cononical.error",
+ file.toString() );
+ throw new LoggingRuntimeException( error, e );
}
}
1.2 +116 -162
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/DefaultLoggingFactory.java
Index: DefaultLoggingFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/DefaultLoggingFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultLoggingFactory.java 24 Jan 2004 23:25:33 -0000 1.1
+++ DefaultLoggingFactory.java 26 Jan 2004 17:36:16 -0000 1.2
@@ -62,12 +62,6 @@
private static final Resources REZ =
ResourceManager.getPackageResources( DefaultLoggingFactory.class );
- public static final String DEFAULT_FORMAT =
- "[%7.7{priority}] (%{category}): %{message}\\n%{throwable}";
-
- public static final Formatter FORMAT =
- new StandardFormatter( DEFAULT_FORMAT );
-
//--------------------------------------------------------------------------
// immutable state
//--------------------------------------------------------------------------
@@ -156,24 +150,25 @@
final LogTargetManager targets = new DefaultLogTargetManager( targetsMap );
//
- // setup the default log target
+ // setup the logging categories directive
+ //
+
+ CategoriesDirective categories =
+ getCategoriesDirective( config.getChild( "categories" ), true );
+
+ //
+ // setup the internal logging channel name
//
- final String name = getRootName( config );
- final String id = getDefaultLoggingTarget( config );
- final String priority = getDefaultLoggingPriority( config );
-
- setupDefaultLogTarget( targetsMap, id );
- CategoriesDirective categories =
- new CategoriesDirective(
- name, priority, id, getInternalCategories( logger, config ) );
+ String internal =
+ config.getChild( "logger" ).getAttribute( "name", "logger" );
//
// create a logkit logging mananager
//
LoggingManager manager =
- new DefaultLoggingManager( targets, categories, false );
+ new DefaultLoggingManager( logger, targets, categories, internal, false );
//
// setup the default log target
@@ -191,44 +186,13 @@
else
{
final String error =
- "Unrecognized criteria class: ["
- + map.getClass().getName();
+ REZ.getString(
+ "factory.bad-criteria",
+ map.getClass().getName() );
throw new IllegalArgumentException( error );
}
}
- /**
- * Map the supplied target as the default target.
- * @param targets the set of establish logging targets
- * @param config the default logging configuration
- */
- private void setupDefaultLogTarget( Map targets, String id )
- throws LoggingException
- {
- if( null == targets.get( id ) )
- {
- if( id.equals( "default" ) )
- {
- LogTarget target = new StreamTarget(
- System.out, FORMAT );
- targets.put( "default", target );
- }
- else
- {
- final String error =
- "Suplied default log target [" + id + "] is unknown.";
- throw new LoggingException( error );
- }
- }
- else
- {
- if( !id.equals( "default" ) )
- {
- targets.put( "default", targets.get( id ) );
- }
- }
- }
-
/**
* Create the log target factories.
*
@@ -257,16 +221,20 @@
}
catch( LoggingException e )
{
- final String error =
- "Cannot load log target factory: [" + key + "].";
- logger.error( error );
+ final String error =
+ REZ.getString( "factory.target-factory.load.error", key );
+ logger.error( error, e );
}
}
else
{
+ final String name = child.getName();
+ final String listing = ConfigurationUtil.list( child );
final String error =
- "Logging target factories contains an unrecognized element:"
- + ConfigurationUtil.list( child );
+ REZ.getString(
+ "factory.target-factory.unknown-element",
+ name,
+ listing );
logger.error( error );
}
}
@@ -301,6 +269,8 @@
}
catch( Throwable e )
{
+ final String message =
+ REZ.getString( "target.notice.fail", child.getName() );
final String error =
"Could not load a declared log target.";
logger.error( error, e );
@@ -324,7 +294,8 @@
final LogTargetFactory factory = manager.getLogTargetFactory( key );
if( factory == null )
{
- final String message = REZ.getString( "target.error.missing", key );
+ final String message =
+ REZ.getString( "target.error.missing-factory", key );
throw new LoggingException( message );
}
else
@@ -347,10 +318,12 @@
}
catch( ConfigurationException e )
{
- final String error =
- "Missing 'type' attribute on target factory declaration:"
- + ConfigurationUtil.list( config );
- throw new LoggingException( error );
+ final String listing = ConfigurationUtil.list( config );
+ final String error =
+ REZ.getString(
+ "target.error.missing-type",
+ listing );
+ throw new LoggingException( error );
}
}
@@ -380,9 +353,11 @@
}
catch( ConfigurationException e )
{
- final String error =
- "Missing 'id' attribute on target declaration:"
- + ConfigurationUtil.list( config );
+ final String listing = ConfigurationUtil.list( config );
+ final String error =
+ REZ.getString(
+ "target.error.missing-id",
+ listing );
throw new LoggingException( error );
}
}
@@ -402,41 +377,15 @@
}
catch( ConfigurationException e )
{
- final String error =
- "Missing 'class' attribute on factory declaration:"
- + ConfigurationUtil.list( config );
+ final String listing = ConfigurationUtil.list( config );
+ final String error =
+ REZ.getString(
+ "target.error.missing-class",
+ listing );
throw new LoggingException( error );
}
}
- public final class StandardLogTargetFactoryManager
- implements LogTargetFactoryManager
- {
- private Map m_map;
-
- /**
- * Creation of a new log target factory manager.
- * @param map the initially empty set of log target factories
- */
- public StandardLogTargetFactoryManager( Map map )
- {
- m_map = map;
- }
-
- /**
- * Retrieves a LogTargetFactory from a name. If
- * this LogTargetFactoryManager does not have the match a null
- * will be returned.
- *
- * @param key name of a LogTargetFactory.
- * @return the LogTargetFactory or null if not found.
- */
- public LogTargetFactory getLogTargetFactory( String key )
- {
- return (LogTargetFactory) m_map.get( key );
- }
- }
-
/**
* Load a factory class using a supplied factory classname.
* @param factory the factory classname
@@ -453,15 +402,17 @@
catch( ClassNotFoundException e )
{
final String error =
- "Could not find the log target factory class: " + classname;
+ REZ.getString(
+ "target.error.class-not-found",
+ classname );
throw new LoggingException( error, e );
}
catch( Throwable e )
{
final String error =
- "Unable to load the log target factory class: ["
- + classname
- + "].";
+ REZ.getString(
+ "target.error.class-load",
+ classname );
throw new LoggingException( error, e );
}
}
@@ -561,12 +512,10 @@
}
catch( NoSuchMethodException eeeeee )
{
- StringBuffer buffer = new StringBuffer();
- buffer.append( "Supplied log factory class [" );
- buffer.append( clazz.getName() );
- buffer.append(
- " ] does not implement a recognized constructor."
);
- throw new LoggingException( buffer.toString() );
+ final String error = REZ.getString(
+ "target.error.bad-factory",
+ clazz.getName() );
+ throw new LoggingException( error );
}
}
}
@@ -596,96 +545,101 @@
catch( Throwable e )
{
final String error =
- "Error while attempting to instantiate the factory: ["
- + clazz.getName()
- + "].";
+ REZ.getString(
+ "target.error.instantiation",
+ clazz.getName() );
throw new LoggingException( error, e );
}
}
- private String getDefaultLoggingPriority( Configuration config )
+ private CategoriesDirective getCategoriesDirective( Configuration config )
+ throws LoggingException
{
- // handle the 3.0-2 legacy style
- final String priority = config.getAttribute( "priority", null );
- if( null != priority ) return priority;
-
- // handle 3.3 full <categories> element
- return config.getChild( "categories" ).getAttribute( "priority", null );
+ return getCategoriesDirective( config, false );
}
- private String getDefaultLoggingTarget( Configuration config )
+ private CategoriesDirective getCategoriesDirective(
+ Configuration config, boolean root )
+ throws LoggingException
{
- // handle the 3.0-2 legacy style
- final String target = config.getAttribute( "target", null );
- if( null != target ) return target;
-
- // handle 3.3 full <categories> element
- return config.getChild( "categories" ).getAttribute( "target", "default" );
+ final String name = getCategoryName( config, root );
+ final String priority = config.getAttribute( "priority", null );
+ final String target = config.getAttribute( "targets", null );
+ CategoryDirective[] categories =
+ getCategoryDirectives( config );
+ return new CategoriesDirective( name, priority, target, categories );
}
- private String getRootName( Configuration config )
+ private String getCategoryName( Configuration config, boolean root )
+ throws LoggingException
{
- // handle the 3.0-2 legacy style
+ if( root ) return "";
final String name = config.getAttribute( "name", null );
if( null != name ) return name;
- // handle 3.3 full <categories> name
- return config.getChild( "categories" ).getAttribute( "name", "root" );
- }
-
- private CategoryDirective[] getInternalCategories(
- Logger logger, Configuration config )
- {
- // handle the 3.0-2 legacy style
- Configuration[] categories = config.getChildren( "category" );
- if( categories.length > 0 )
- {
- return createCategories( logger, categories );
- }
-
- // handle 3.3 full <categories> element
- return createCategories(
- logger,
- config.getChild( "categories" ).getChildren( "category" ) );
+ final String error =
+ REZ.getString( "target.error.missing-category-name" );
+ throw new LoggingException( error );
}
- private CategoryDirective[] createCategories(
- Logger logger, Configuration[] configs )
+ private CategoryDirective[] getCategoryDirectives( Configuration config )
+ throws LoggingException
{
ArrayList list = new ArrayList();
- for( int i=0; i<configs.length; i++ )
+ Configuration[] children = config.getChildren();
+ for( int i=0; i<children.length; i++ )
{
- Configuration config = configs[i];
- try
+ Configuration child = children[i];
+ if( child.getName().equals( "category" ) )
{
- CategoryDirective category = createCategory( config );
- list.add( category );
+ CategoryDirective directive =
+ getCategoryDirective( child );
+ list.add( directive );
}
- catch( LoggingException e )
+ else if( child.getName().equals( "categories" ) )
{
- final String error =
- "Ignoring invalid category directive:"
- + ConfigurationUtil.list( config );
- logger.error( error, e );
+ CategoriesDirective directive =
+ getCategoriesDirective( child );
+ list.add( directive );
}
}
return (CategoryDirective[]) list.toArray( new CategoryDirective[0] );
}
- private CategoryDirective createCategory( Configuration config )
+ private CategoryDirective getCategoryDirective( Configuration config )
throws LoggingException
{
- final String name = config.getAttribute( "name", null );
- if( null == name )
- {
- final String error =
- "Missing category 'name' attribute.";
- throw new LoggingException( error );
- }
+ final String name = getCategoryName( config, false );
final String priority = config.getAttribute( "priority", null );
final String target = config.getAttribute( "targets", null );
return new CategoryDirective( name, priority, target );
}
-
+ public final class StandardLogTargetFactoryManager
+ implements LogTargetFactoryManager
+ {
+ private Map m_map;
+
+ /**
+ * Creation of a new log target factory manager.
+ * @param map the initially empty set of log target factories
+ */
+ public StandardLogTargetFactoryManager( Map map )
+ {
+ m_map = map;
+ }
+
+ /**
+ * Retrieves a LogTargetFactory from a name. If
+ * this LogTargetFactoryManager does not have the match a null
+ * will be returned.
+ *
+ * @param key name of a LogTargetFactory.
+ * @return the LogTargetFactory or null if not found.
+ */
+ public LogTargetFactory getLogTargetFactory( String key )
+ {
+ return (LogTargetFactory) m_map.get( key );
+ }
+ }
}
1.2 +71 -46
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/DefaultLoggingManager.java
Index: DefaultLoggingManager.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/DefaultLoggingManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultLoggingManager.java 24 Jan 2004 23:25:33 -0000 1.1
+++ DefaultLoggingManager.java 26 Jan 2004 17:36:16 -0000 1.2
@@ -32,12 +32,14 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.logging.data.CategoryDirective;
import org.apache.avalon.logging.data.CategoriesDirective;
+import org.apache.avalon.logging.provider.LoggingRuntimeException;
import org.apache.log.Hierarchy;
import org.apache.log.LogTarget;
import org.apache.log.Priority;
import org.apache.log.output.io.FileTarget;
import org.apache.log.output.io.StreamTarget;
+import org.apache.log.format.Formatter;
/**
* A <code>LoggerManager</code> interface declares operation supporting
@@ -56,7 +58,11 @@
private static final String DEFAULT_PRIORITY = "INFO";
- private static final String DEFAULT_TARGET = "default";
+ public static final String DEFAULT_FORMAT =
+ "[%7.7{priority}] (%{category}): %{message}\\n%{throwable}";
+
+ public static final Formatter FORMAT =
+ new StandardFormatter( DEFAULT_FORMAT );
//---------------------------------------------------------------
// immutable state
@@ -73,14 +79,18 @@
private final Hierarchy m_hierarchy = new Hierarchy();
/**
- * The bootstrap logging channel.
+ * Debug mode flag.
*/
- private final Logger m_logger;
+ private final boolean m_debug;
+
+ //--------------------------------------------------------------
+ // mutable state
+ //--------------------------------------------------------------
/**
- * Debug mode flag.
+ * The logging channel.
*/
- private final boolean m_debug;
+ private Logger m_logger;
//--------------------------------------------------------------
// constructor
@@ -95,7 +105,8 @@
* @param debug a debug flag
*/
public DefaultLoggingManager(
- LogTargetManager targets, CategoriesDirective categories, boolean debug )
+ Logger logger, LogTargetManager targets, CategoriesDirective categories,
+ String channel, boolean debug )
throws Exception
{
if( null == targets )
@@ -105,6 +116,7 @@
m_debug = debug;
m_targets = targets;
+ m_logger = logger;
//
// setup the default logging priority
@@ -112,8 +124,9 @@
if( !debug )
{
+ String priority = getDefaultPriority( categories );
getHierarchy().setDefaultPriority(
- Priority.getPriorityForName( categories.getPriority() ) );
+ Priority.getPriorityForName( priority ) );
}
else
{
@@ -121,43 +134,33 @@
Priority.getPriorityForName( "DEBUG" ) );
}
- LogTarget target = targets.getLogTarget( "default" );
+ LogTarget target = getDefaultLogTarget( categories );
getHierarchy().setDefaultLogTarget( target );
- m_logger = setupInternalLogger( categories );
- m_logger.debug( "logging system established" );
+
addCategories( categories );
- }
- private Logger setupInternalLogger( CategoriesDirective directive )
- {
- final String root = directive.getName();
- final CategoryDirective category = directive.getCategoryDirective( "logger"
);
- final String priority = getLoggingChannelPriority( directive, category );
- final String target = getLoggingChannelTarget( directive, category );
- final String path = root + ".logger";
- return new LogKitLogger( addCategory( path, priority, target ) );
+ m_logger = getLoggerForCategory( channel );
+ m_logger.debug( "logging system established" );
}
- private String getLoggingChannelPriority(
- CategoriesDirective directive, CategoryDirective category )
+ private LogTarget getDefaultLogTarget( CategoriesDirective categories )
+ throws LoggingException
{
- if( null != category )
- {
- String priority = category.getPriority();
- if( null != priority ) return priority;
+ String id = categories.getTarget();
+ if( null == id )
+ {
+ return new StreamTarget( System.out, FORMAT );
}
- return directive.getPriority();
- }
-
- private String getLoggingChannelTarget(
- CategoriesDirective directive, CategoryDirective category )
- {
- if( null != category )
- {
- String target = category.getTarget();
+ else
+ {
+ LogTarget target = m_targets.getLogTarget( id );
if( null != target ) return target;
+
+ final String error =
+ REZ.getString(
+ "manager.invalid-default-target", id );
+ throw new LoggingException( error );
}
- return directive.getTarget();
}
private String getDefaultPriority( CategoriesDirective categories )
@@ -200,21 +203,28 @@
for( int i = 0; i < categories.length; i++ )
{
CategoryDirective category = categories[i];
- final String priority = category.getPriority();
- final String target = category.getTarget();
final String name = filter( category.getName() );
- if( path.equals( "" ) )
+ final String base = getBasePath( path, name );
+ if( category instanceof CategoriesDirective )
{
- addCategory( name, priority, target );
+ CategoriesDirective c = (CategoriesDirective) category;
+ addCategories( base, c );
}
else
{
- final String base = filter( path + "." + name );
+ final String priority = category.getPriority();
+ final String target = category.getTarget();
addCategory( base, priority, target );
}
}
}
+ private String getBasePath( String root, String name )
+ {
+ if( root.equals( "" ) ) return name;
+ return filter( root + "." + name );
+ }
+
/**
* Return the Logger for the specified category.
* @param category the category path
@@ -246,22 +256,34 @@
{
if( !name.equals( "" ) )
{
- debug( "adding category: " + name + ", " + priority.toLowerCase() );
+ final String message =
+ REZ.getString(
+ "manager.notify.add-category", name, priority.toLowerCase() );
+ debug( message );
}
else
{
- debug( "adding root category with priority: " +
priority.toLowerCase() );
+ final String message =
+ REZ.getString(
+ "manager.notify.add-root-category", priority.toLowerCase() );
+ debug( message );
}
}
else
{
if( !name.equals( "" ) )
{
- debug( "adding category: " + name );
+ final String message =
+ REZ.getString(
+ "manager.notify.add-default-category", name );
+ debug( message );
}
else
{
- debug( "adding root category" );
+ final String message =
+ REZ.getString(
+ "manager.notify.add-default-root" );
+ debug( message );
}
}
@@ -271,7 +293,10 @@
}
catch( Throwable e )
{
- throw new RuntimeException( "Bad category: " + name );
+ final String error =
+ REZ.getString(
+ "manager.error.internal", name );
+ throw new LoggingRuntimeException( error, e );
}
if( !m_debug && priority != null )
@@ -280,7 +305,7 @@
if( !priorityValue.getName().equals( priority ) )
{
final String message =
- REZ.getString( "unknown-priority", priority, name );
+ REZ.getString( "manager.error.priority", priority, name );
throw new IllegalArgumentException( message );
}
logger.setPriority( priorityValue );
1.2 +32 -20
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/Resources.properties
Index: Resources.properties
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/Resources.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Resources.properties 24 Jan 2004 23:25:33 -0000 1.1
+++ Resources.properties 26 Jan 2004 17:36:16 -0000 1.2
@@ -1,21 +1,33 @@
-builder.redundent-role.notice=Warning: Type for class {0} redundently specifies
role name "{1}" in dependency when it is identical to the name of service. It is
recomended that the <role/> section be elided.
-builder.creating-info.notice=Creating a Type for class "{0}".
-builder.created-info.notice=Constructed Type object for class {0}. Type contains
{1} services, {2} dependencies, {3} context entrys and {4} loggers.
-builder.bad-toplevel-element.error=Error the component implemented by "{0}" has an
invalid element at top level of component info descriptor. Expected: "component-info".
Actual: "{1}"
-builder.missing-info.error=Unable to locate resource from which to load info for
component implemented by class "{0}".
-builder.missing-xml-creator.error=Unable to create XMLTypeCreator, usually due to
not having XML classes on Classpath. Thus unable to lookup XML descriptor for
component type "{0}".
-
-builder.creating-profile.notice=Creating Profiles for class "{0}".
-
-target.nocreate=Error creating LogTarget named "{0}" for file {0}. (Reason: {2}).
-unknown-priority=Unknown priority "{0}" for Logger named "{1}".
-category-create=Creating a log category named "{0}" that writes to "{1}" target at
priority "{2}".
-
-missing.extension=Unable to locate an extension that is required by application.\n
Extension Name: {0}\n Specification Vendor: {1}\n Specification Version: {2}\n
Implementation Vendor: {3}\n Implementation Vendor-Id: {4}\n Implementation Version:
{5}\n Implementation URL: {6}
-unsatisfied.extensions=Missing {0} extensions and thus can not build ClassLoader
for application.
-bad-classpath-entry=There is a bad entry ("{0}") on classpath that made it
impossible to load a manifest.
-available-extensions=Available extensions: {0}
-required-extensions=The list of required extensions for application includes: {0}
-optional-packages-added=The list of "Optional Packages" added to the application
include: {0}
-classpath-entries=The list of classpath entrys for the application include: {0}
+target.notice.add=Adding log target [{0}].
+target.notice.fail=Could not load a declared log target [{0}].
+
+target.error.missing-factory=Log target factory key [{0}] is unknown.
+target.error.missing-type=Missing 'type' attribute on target factory declaration.{0}
+target.error.missing-id=Missing 'id' attribute on target declaration.{0}
+target.error.missing-class=Missing 'class' attribute on target declaration.{0}
+target.error.class-not-found=Could not find the log target factory class: [{0}].
+target.error.class-load=Could not load the log target factory class: [{0}].
+target.error.bad-factory=Supplied log factory class: [{0}] does not implement a
recognized constructor.
+target.error.instantiation=Error while attempting to instantiate the factory: [{0}].
+target.error.missing-category-name=Missing category 'name' attribute.
+
+parameter.unknown=Don't know how to transform an instance of [{0}] to an instance
of [{1}].
+
+parameter.configuration.fnf.error=Configuration file not found [{0}].
+parameter.configuration.file.error=File to configuration convertion error from
source [{0}].
+parameter.configuration.url.error=URL to configuration convertion error from source
[{0}].
+
+criteria.artifact.default.error=Unable to resolve cononical representation of the
file [{0}].
+
+factory.bad-criteria=Unrecognized criteria class [{0}].
+factory.target-factory.load.error=Cannot load log target factory [{0}].
+factory.target-factory.unknown-element=Logging target factories configuration
contains an unrecognized element [{0}]. [{1}]
+
+manager.invalid-default-target=Supplied default log target [{0}] is unknown.
+manager.notify.add-category=adding root category [{0}] with priority: [{1}].
+manager.notify.add-root-category=adding root category with priority: [{0}].
+manager.notify.add-default-category=adding category: [{0}].
+manager.notify.add-default-root=adding root category.
+manager.error.internal=Internal error while getting logging channel for category
[{0}].
+manager.error.priority=Unrecognized priority [{0}] for the category [{1}].
1.2 +29 -10
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory/DatagramTargetFactory.java
Index: DatagramTargetFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory/DatagramTargetFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DatagramTargetFactory.java 24 Jan 2004 23:25:33 -0000 1.1
+++ DatagramTargetFactory.java 26 Jan 2004 17:36:16 -0000 1.2
@@ -57,6 +57,9 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+
import org.apache.log.LogTarget;
import org.apache.log.format.ExtendedPatternFormatter;
import org.apache.log.format.Formatter;
@@ -67,6 +70,7 @@
import org.apache.avalon.logging.logkit.LogTargetException;
import org.apache.avalon.logging.logkit.LogTargetFactory;
+
/**
* This factory creates LogTargets with a wrapped DatagramOutputTarget around it.
* <p>
@@ -92,12 +96,26 @@
*/
public class DatagramTargetFactory implements LogTargetFactory
{
- /** Default format */
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DatagramTargetFactory.class );
+
private static final String FORMAT =
- "%7.7{priority} %5.5{time} [%8.8{category}] (%{context}):
%{message}\\n%{throwable}";
+ "%7.7{priority} %5.5{time} "
+ + "[%8.8{category}] (%{context}): %{message}\\n%{throwable}";
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
/**
- * Create a LogTarget based on a Configuration
+ * Create a LogTarget based on a supplied configuration
+ * @param conf the target coonfiguration
+ * @return the datagram target
+ * @exception LogTargetException if a target creation error occurs
*/
public LogTarget createTarget( final Configuration conf )
throws LogTargetException
@@ -108,7 +126,7 @@
if( null == configChild )
{
final String error =
- "target address not specified in the config";
+ REZ.getString( "datagram.error.missing-address" );
throw new LogTargetException( error );
}
@@ -121,17 +139,18 @@
catch( UnknownHostException uhex )
{
final String error =
- "Host specified in datagram target adress is unknown.";
+ REZ.getString( "datagram.error.unknown-host" );
throw new LogTargetException( error, uhex );
}
catch( ConfigurationException e )
{
final String error =
- "missing hostname attribute on datagram target.";
+ REZ.getString( "datagram.error.missing-host" );
throw new LogTargetException( error, e );
}
- final Formatter formatter = getFormatter( conf.getChild( "format", false )
);
+ final Formatter formatter =
+ getFormatter( conf.getChild( "format", false ) );
try
{
@@ -140,14 +159,14 @@
}
catch( IOException ioex )
{
- final String error =
- "Failed to create target.";
+ final String error =
+ REZ.getString( "datagram.error.internal" );
throw new LogTargetException( error, ioex );
}
catch( ConfigurationException e )
{
final String error =
- "missing port attribute on datagram target.";
+ REZ.getString( "datagram.error.missing-port" );
throw new LogTargetException( error, e );
}
}
1.2 +33 -9
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory/FileTargetFactory.java
Index: FileTargetFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory/FileTargetFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FileTargetFactory.java 24 Jan 2004 23:25:33 -0000 1.1
+++ FileTargetFactory.java 26 Jan 2004 17:36:16 -0000 1.2
@@ -61,6 +61,9 @@
import org.apache.avalon.logging.logkit.LogTargetFactory;
import org.apache.avalon.logging.logkit.LogTargetException;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+
import org.apache.log.LogTarget;
import org.apache.log.format.Formatter;
import org.apache.log.output.io.FileTarget;
@@ -75,7 +78,7 @@
import org.apache.log.output.io.rotate.RotatingFileTarget;
import org.apache.log.output.io.rotate.UniqueFileStrategy;
-import org.apache.avalon.logging.logkit.DefaultLoggingFactory;
+import org.apache.avalon.logging.logkit.DefaultLoggingManager;
/**
@@ -172,6 +175,13 @@
*/
public class FileTargetFactory implements LogTargetFactory
{
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DatagramTargetFactory.class );
+
private static final long SECOND = 1000;
private static final long MINUTE = 60 * SECOND;
private static final long HOUR = 60 * MINUTE;
@@ -180,13 +190,25 @@
private static final long KILOBYTE = 1000;
private static final long MEGABYTE = 1000 * KILOBYTE;
+ //--------------------------------------------------------------
+ // immutable state
+ //--------------------------------------------------------------
+
private final File m_basedir;
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
public FileTargetFactory( File basedir )
{
m_basedir = basedir;
}
+ //--------------------------------------------------------------
+ // LogFactory
+ //--------------------------------------------------------------
+
/**
* Create a LogTarget based on a Configuration
*/
@@ -225,7 +247,7 @@
if( confRotation.getChildren().length == 0 )
{
final String error =
- "Missing file rotation strategy element
[or|size|date|interval|time]";
+ REZ.getString( "file.error.missing-rotation" );
throw new LogTargetException( error );
}
final Configuration confStrategy =
@@ -243,25 +265,27 @@
catch( Throwable e )
{
final String error =
- "LogKit error while attempting to construct rotatying file
target.";
+ REZ.getString( "file.error.logkit-rotation" );
throw new LogTargetException( error, e );
}
}
}
- catch( final IOException ioe )
+ catch( final IOException e )
{
- throw new LogTargetException( "Cannot create FileTarget.", ioe );
+ final String error =
+ REZ.getString( "file.error.io" );
+ throw new LogTargetException( error, e );
}
catch( ConfigurationException e )
{
final String error =
- "Incomplete file target configuration.";
+ REZ.getString( "file.error.config" );
throw new LogTargetException( error, e );
}
catch( Throwable e )
{
final String error =
- "Internal error while attempting to construct file log target.";
+ REZ.getString( "file.error.internal" );
throw new LogTargetException( error, e );
}
}
@@ -424,7 +448,7 @@
return formatterFactory.createFormatter( conf );
}
- return DefaultLoggingFactory.FORMAT;
+ return DefaultLoggingManager.FORMAT;
}
}
1.2 +34 -10
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory/FormatterFactory.java
Index: FormatterFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory/FormatterFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FormatterFactory.java 24 Jan 2004 23:25:33 -0000 1.1
+++ FormatterFactory.java 26 Jan 2004 17:36:16 -0000 1.2
@@ -53,6 +53,9 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.logger.AvalonFormatter;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+
import org.apache.log.format.ExtendedPatternFormatter;
import org.apache.log.format.Formatter;
import org.apache.log.format.PatternFormatter;
@@ -60,22 +63,39 @@
import org.apache.log.format.SyslogFormatter;
import org.apache.log.format.XMLFormatter;
-import org.apache.avalon.logging.logkit.DefaultLoggingFactory;
+import org.apache.avalon.logging.logkit.DefaultLoggingManager;
/**
* Factory for Formatter-s.
*/
public class FormatterFactory
{
- private static final String FORMAT = DefaultLoggingFactory.DEFAULT_FORMAT;
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( FormatterFactory.class );
+
+ private static final String FORMAT = DefaultLoggingManager.DEFAULT_FORMAT;
+ //--------------------------------------------------------------
+ // implementation
+ //--------------------------------------------------------------
+
+ /**
+ * Creation of a new formatter using a supplied configuration.
+ * @param config the formatter configuration
+ * @return the formatter instance
+ * @exception IllegalArgumentException if the formatter type is unknown
+ */
public Formatter createFormatter( final Configuration conf )
{
final String type = conf.getAttribute( "type", "pattern" );
final String format = conf.getValue( FORMAT );
if( "merlin".equals( type ) )
{
- return DefaultLoggingFactory.FORMAT;
+ return DefaultLoggingManager.FORMAT;
}
else if( "avalon".equals( type ) )
{
@@ -91,12 +111,14 @@
}
else if( "extended".equals( type ) )
{
- /*Normally ExtendPatternFormatter would look for callers
- *of Logger.class. But when Excalibur Logger provides a
- *facade, the user class/method is actually one-level deeper.
- *We therefore create the pattern-formatter with an
- *additional depth-offset of 1.
- */
+ //
+ // Normally ExtendPatternFormatter would look for callers
+ // of Logger.class. But when Excalibur Logger provides a
+ // facade, the user class/method is actually one-level deeper.
+ // We therefore create the pattern-formatter with an
+ // additional depth-offset of 1.
+ //
+
return new ExtendedPatternFormatter( format, 1 );
}
else if( "raw".equals( type ) )
@@ -117,7 +139,9 @@
}
else
{
- throw new IllegalArgumentException( "Unknown formatter type " + type );
+ final String error =
+ REZ.getString( "formatter.error.unknown-type", type );
+ throw new IllegalArgumentException( error );
}
}
}
1.2 +29 -12
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory/SocketTargetFactory.java
Index: SocketTargetFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory/SocketTargetFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SocketTargetFactory.java 24 Jan 2004 23:25:33 -0000 1.1
+++ SocketTargetFactory.java 26 Jan 2004 17:36:16 -0000 1.2
@@ -56,6 +56,9 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+
import org.apache.avalon.logging.logkit.LogTargetFactory;
import org.apache.avalon.logging.logkit.LogTargetException;
@@ -85,6 +88,17 @@
*/
public class SocketTargetFactory implements LogTargetFactory
{
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( SocketTargetFactory.class );
+
+ //--------------------------------------------------------------
+ // TargetFactory
+ //--------------------------------------------------------------
+
/**
* Creates a log target based on Configuration
*
@@ -97,10 +111,13 @@
{
final InetAddress address;
- final Configuration configChild = conf.getChild( "address", false );
+ final Configuration configChild =
+ conf.getChild( "address", false );
if( null == configChild )
{
- throw new LogTargetException( "target address not specified in the
config" );
+ final String error =
+ REZ.getString( "socket.error.missing-address" );
+ throw new LogTargetException( error );
}
try
@@ -111,14 +128,14 @@
}
catch( UnknownHostException uhex )
{
- throw new LogTargetException(
- "Host specified in socket target adress is unknown!",
- uhex );
+ final String error =
+ REZ.getString( "socket.error.unknown-host" );
+ throw new LogTargetException( error, uhex );
}
catch( ConfigurationException e )
{
final String error =
- "Missing 'hostname' attribute in socket target factory.";
+ REZ.getString( "socket.error.missing-host" );
throw new LogTargetException( error, e );
}
@@ -127,17 +144,17 @@
final int port = configChild.getAttributeAsInteger( "port" );
return new SocketOutputTarget( address, port );
}
- catch( final IOException ioex )
+ catch( ConfigurationException e )
{
- throw new LogTargetException(
- "Failed to create target!", ioex.fillInStackTrace() );
+ final String error =
+ REZ.getString( "socket.error.missing-port" );
+ throw new LogTargetException( error, e );
}
- catch( ConfigurationException e )
+ catch( Throwable e )
{
final String error =
- "Missing 'port' attribute in socket target factory.";
+ REZ.getString( "socket.error.internal" );
throw new LogTargetException( error, e );
}
-
}
}
1.1
avalon/merlin/logging/logkit/impl/src/java/org/apache/avalon/logging/logkit/factory/Resources.properties
Index: Resources.properties
===================================================================
datagram.error.missing-address=Missing 'address' attribute is supplied datagram
target configuration.
datagram.error.unknown-host=Datagram target references an unknown host.
datagram.error.missing-host=Datagram target does not contain required 'hostname'
attribute.
datagram.error.internal=Internal error while attempting to construct datagram target.
datagram.error.missing-port=Datagram target does not contain required 'port'
attribute.
file.error.missing-rotation=Missing file rotation strategy element. The file target
must contain a single rotation strategy child element named
[or|size|date|interval|time].
file.error.logkit-rotation=LogKit error while attempting to construct rotating file
target.
file.error.io=IOException while attempting to construct file target.
file.error.config=File target configuration error.
file.error.internal=Internal error while attempting to construct file log target.
formatter.error.unknown-type=Unknown formatter type [{0}].
socket.error.missing-address=Missing 'address' attribute is supplied socket target
configuration.
socket.error.unknown-host=Socket target references an unknown host.
socket.error.missing-host=Socket target does not contain required 'hostname'
attribute.
socket.error.missing-port=Socket target does not contain required 'port' attribute.
socket.error.internal=Internal error while attempting to construct socket target.
1.2 +10 -0 avalon/merlin/logging/logkit/test/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/avalon/merlin/logging/logkit/test/project.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- project.xml 24 Jan 2004 23:25:33 -0000 1.1
+++ project.xml 26 Jan 2004 17:36:16 -0000 1.2
@@ -19,5 +19,15 @@
<artifactId>avalon-repository-main</artifactId>
<version>1.3-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework-api</artifactId>
+ <version>4.1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon-logging</groupId>
+ <artifactId>avalon-logging-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
1.2 +25 -5 avalon/merlin/logging/logkit/test/conf/logging.xml
Index: logging.xml
===================================================================
RCS file: /home/cvs/avalon/merlin/logging/logkit/test/conf/logging.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- logging.xml 24 Jan 2004 23:25:33 -0000 1.1
+++ logging.xml 26 Jan 2004 17:36:16 -0000 1.2
@@ -2,17 +2,19 @@
<logging>
- <categories priority="info" name="kernel" target="simple">
- <category name="logger" priority="debug"/>
- <category name="fred" priority="info" target="simple"/>
- <category name="roger" priority="error"/>
- </categories>
+ <!--
+ Declaration of the log target factories.
+ -->
<factories>
<factory type="file"
class="org.apache.avalon.logging.logkit.factory.FileTargetFactory"/>
</factories>
+ <!--
+ Declaration of the named log target.
+ -->
+
<targets>
<file id="simple">
<filename>simple.log</filename>
@@ -22,5 +24,23 @@
</rotation>
</file>
</targets>
+
+ <!--
+ Declaration of the initial logging categories.
+ -->
+
+ <categories priority="info" target="simple">
+ <categories name="kernel">
+ <category name="logger" priority="debug"/>
+ <category name="roger-ramjet" priority="error"/>
+ </categories>
+ </categories>
+
+ <!--
+ Selection of the logging channel for use by the logging
+ system following establishment.
+ -->
+
+ <logger name="kernel.logger"/>
</logging>
1.3 +2 -1
avalon/merlin/logging/logkit/test/src/test/org/apache/avalon/logging/logkit/test/DefaultLoggingManagerTestCase.java
Index: DefaultLoggingManagerTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/logging/logkit/test/src/test/org/apache/avalon/logging/logkit/test/DefaultLoggingManagerTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultLoggingManagerTestCase.java 25 Jan 2004 13:18:49 -0000 1.2
+++ DefaultLoggingManagerTestCase.java 26 Jan 2004 17:36:16 -0000 1.3
@@ -81,6 +81,7 @@
File file = new File( basedir, "conf/logging.xml" );
File target = new File( basedir, "target" );
+ criteria.put( "avalon.logging.bootstrap", "debug" );
criteria.put( "avalon.logging.configuration", file );
criteria.put( "avalon.logging.basedir", target );
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]