/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
*/
/**
* This class encapsulates the trace settings in effect at a given traceing
* scope.
*/
public class TraceSettings
implements ConfigurationChangeListener<DebugTargetCfg>
{
/** A TraceSettings object representing a fully disabled trace state. */
/**
* The log level of this setting.
*/
/**
* The log categories for this setting.
*/
/**
* Indicates if method arguments should be logged.
*/
boolean noArgs;
/**
* Indicates if method return values should be logged.
*/
boolean noRetVal;
/**
* The level of stack frames to include.
*/
int stackDepth;
/**
* Indicates if the cause exception is included in exception messages.
*/
boolean includeCause;
/**
* Construct new trace settings at the specified log level.
*
* @param level the log level for this setting.
*/
{
}
/**
* Construct new trace settings at the specified log level and including
* the categories.
*
* @param level the log level for this setting.
* @param includeCategories the categories to include in this setting.
*/
{
}
/**
* Construct new trace settings at the specified log level and including
* the categories. Optionally turn off arguments and return value in entry
* and exit messages.
*
* @param level the log level for this setting.
* @param includeCategories the categories to include in this setting.
* @param noArgs whether to include arguments in the log messages.
* @param noRetVal whether to include return values in the log messages.
*/
{
}
/**
* Construct new trace settings at the specified log level and including
* the categories. Optionally turn off arguments, return value in entry
* and exit messages, and specifying the depth of stack traces and whether
* to include the cause of exceptions.
*
* @param level the log level for this setting.
* @param includeCategories the categories to include in this setting.
* @param noArgs whether to include arguments in the log messages.
* @param noRetVal whether to include return values in the log messages.
* @param stackDepth the stack depth to display in log messages.
* @param includeCause whether to include the cause of exceptions.
*/
boolean includeCause)
{
this.includeCategories = includeCategories;
this.stackDepth = stackDepth;
this.includeCause = includeCause;
}
/**
* Construct a new trace settings from the provided configuration.
*
* @param config The debug target configuration that contains the information
* to use to initialize this trace setting.
*/
{
this.level =
{
{
}
}
this.includeCategories = logCategories;
config.addChangeListener(this);
}
/**
* {@inheritDoc}
*/
public boolean isConfigurationChangeAcceptable(
{
// This should alwas be acceptable. We are assuing that the scope for this
// trace setting is the same sine its part of the DN.
return true;
}
/**
* {@inheritDoc}
*/
{
// Default result code.
boolean adminActionRequired = false;
// We can assume that the target scope did not change since its the
// naming attribute. Changing it would result in a modify DN.
this.level =
{
{
}
}
this.includeCategories = logCategories;
this.currentConfig = config;
}
/**
* Parse trace settings from the string representation.
*
* @param value the trace settings string to be parsed.
* @return the trace settings parsed from the string.
*/
{
{
//Touch DebugLogLevel and DebugLogCategory so they are statically
//initialized or parse will not see all the levels/categories.
boolean noArgs = false;
boolean noRetVal = false;
int stackDepth = 0;
boolean includeCause = false;
{
//See if stack dump keyword is included
{
//See if a stack depth is included
{
}
else
{
{
try
{
}
catch(NumberFormatException nfe)
{ // TODO: i18n
" contains an invalid depth value. The complete stack " +
"will be included.");
}
}
}
}
//See if to include cause in exception messages.
{
includeCause = true;
}
//See if to supress method arguments.
{
noArgs = true;
}
//See if to supress return values.
{
noRetVal = true;
}
{
int categoryStart =
{ // TODO: i18n
" does not contain an equal sign to define the set of " +
"categories to include. All categories will be included.");
}
else
{
String[] categories =
{
try
{
}
catch(IllegalArgumentException iae)
{ // TODO: i18n
" contains an invalid debug log category: " +
}
}
}
}
{
int levelStart =
{ // TODO: i18n
" does not contain an equal sign to specify the log level. " +
}
else
{
try
{
}
catch(IllegalArgumentException iae)
{ // TODO: i18n
" contains an invalid debug log level: " +
" will be used.");
}
}
}
}
}
return settings;
}
/**
* Get the log level of this setting.
* @return the log level of this setting.
*/
return level;
}
/**
* Get the log categories for this setting.
* @return the log categories for this setting.
*/
}
/**
* Get whether method arguments should be logged.
* @return if method arguments should be logged.
*/
public boolean isNoArgs() {
return noArgs;
}
/**
* Get whether method return values should be logged.
* @return if method return values should be logged.
*/
public boolean isNoRetVal() {
return noRetVal;
}
/**
* Get the level of stack frames to include.
* @return the level of stack frames to include.
*/
public int getStackDepth() {
return stackDepth;
}
/**
* Get whether the cause exception is included in exception messages.
* @return if the cause exception is included in exception messages.
*/
public boolean isIncludeCause() {
return includeCause;
}
}