This class acts as a container for Loggers and provides a convenient interface to logging. Fore information how to use this class, checkout the ALox tutorials and the ALox User Manual.
Inner Classes | |
class | DomainSubstitutionRule |
enum | DSRType |
Public Static Fields | |
static final int | STATE_INFO_ALL = ~0 |
All information available. | |
static final int | STATE_INFO_BASIC = 1 << 0 |
Name and number of log calls. | |
static final int | STATE_INFO_DOMAINS = 1 << 3 |
Domains currently registered. | |
static final int | STATE_INFO_DSR = 1 << 6 |
Domain substitution rules. | |
static final int | STATE_INFO_INTERNAL_DOMAINS = 1 << 4 |
Internal domains. | |
static final int | STATE_INFO_LOG_DATA = 1 << 9 |
Log data objects. | |
static final int | STATE_INFO_LOGGERS = 1 << 2 |
Loggers. | |
static final int | STATE_INFO_ONCE = 1 << 8 |
Log once counters. | |
static final int | STATE_INFO_PREFIX_LOGABLES = 1 << 7 |
Prefix logables. | |
static final int | STATE_INFO_SCOPE_DOMAINS = 1 << 5 |
Scope domains. | |
static final int | STATE_INFO_THREAD_MAPPINGS = 1 << 10 |
Named threads. | |
static final int | STATE_INFO_VERSION = 1 << 1 |
Library Version and thread safeness. | |
Public Fields | |
int | cntLogCalls = 0 |
Vector< String > | omittablePackagePrefixes |
Public Fields inherited from ThreadLock | |
int | recursionWarningThreshold = 10 |
int | waitWarningTimeLimitInMillis = 1000 |
Public Static Methods | |
static TextLogger | createConsoleLogger () |
static TextLogger | createConsoleLogger (String name) |
Public Methods | |
Lox (String name) | |
Lox (String name, boolean doRegister) | |
void | acquire () |
void | Assert (boolean condition, Object... logables) |
void | entry (String domain, Verbosity verbosity, Object... logables) |
void | entryDetectDomain (Verbosity verbosity, Object... logables) |
void | error (Object... logables) |
Logger | getLogger (String loggerName) |
String | getName () |
void | getState (AString buf, int flags) |
void | If (boolean condition, String domain, Verbosity verbosity, Object... logables) |
void | If (boolean condition, Verbosity verbosity, Object... logables) |
void | info (Object... logables) |
boolean | isRegistered () |
void | mapThreadName (String threadName) |
void | mapThreadName (String threadName, long id) |
void | once (Object logables) |
void | once (Object logables, int quantity) |
void | once (Object logables, int quantity, Scope scope) |
void | once (Object logables, int quantity, Scope scope, int pkgLevel) |
void | once (Object logables, int quantity, String group) |
void | once (String domain, Verbosity verbosity, Object logables) |
void | once (String domain, Verbosity verbosity, Object logables, int quantity) |
void | once (String domain, Verbosity verbosity, Object logables, Scope scope) |
void | once (String domain, Verbosity verbosity, Object logables, Scope scope, int pkgLevel) |
void | once (String domain, Verbosity verbosity, Object logables, Scope scope, int pkgLevel, int quantity) |
void | once (String domain, Verbosity verbosity, Object logables, String group) |
void | once (String domain, Verbosity verbosity, Object logables, String group, int quantity) |
void | once (String domain, Verbosity verbosity, Object logables, String group, Scope scope) |
void | once (String domain, Verbosity verbosity, Object logables, String group, Scope scope, int pkgLevel) |
void | once (String domain, Verbosity verbosity, Object logables, String group, Scope scope, int pkgLevel, int quantity) |
void | release () |
boolean | removeLogger (Logger logger) |
Logger | removeLogger (String loggerName) |
void | removeThreadDomain (String scopeDomain, Scope scope) |
void | removeThreadDomain (String scopeDomain, Scope scope, Thread thread) |
Object | retrieve () |
Object | retrieve (Scope scope) |
Object | retrieve (Scope scope, int pkgLevel) |
Object | retrieve (String key) |
Object | retrieve (String key, Scope scope) |
Object | retrieve (String key, Scope scope, int pkgLevel) |
void | setDomain (String scopeDomain, Scope scope) |
void | setDomain (String scopeDomain, Scope scope, int packageLevel) |
void | setDomain (String scopeDomain, Scope scope, Thread thread) |
void | setDomainSubstitutionRule (String domainPath, String replacement) |
void | setPrefix (Object logable) |
void | setPrefix (Object logable, String domain) |
void | setPrefix (Object prefix, Scope scope) |
void | setPrefix (Object prefix, Scope scope, int packageLevel) |
void | setPrefix (Object prefix, Scope scope, Thread thread) |
void | setPrefix (Object prefix, String domain, Inclusion otherPLs) |
void | setStartTime () |
void | setStartTime (Date startTime) |
void | setStartTime (Date startTime, String loggerName) |
void | setVerbosity (Logger logger, Verbosity verbosity) |
void | setVerbosity (Logger logger, Verbosity verbosity, String domain) |
void | setVerbosity (Logger logger, Verbosity verbosity, String domain, int priority) |
void | setVerbosity (String loggerName, Verbosity verbosity) |
void | setVerbosity (String loggerName, Verbosity verbosity, String domain) |
void | setVerbosity (String loggerName, Verbosity verbosity, String domain, int priority) |
void | state (String domain, Verbosity verbosity, String headLine) |
void | state (String domain, Verbosity verbosity, String headLine, int flags) |
void | store (Object data) |
void | store (Object data, Scope scope) |
void | store (Object data, Scope scope, int pkgLevel) |
void | store (Object data, String key) |
void | store (Object data, String key, Scope scope) |
void | store (Object data, String key, Scope scope, int pkgLevel) |
void | verbose (Object... logables) |
void | warning (Object... logables) |
Public Methods inherited from ThreadLock | |
ThreadLock () | |
ThreadLock (LockMode lockMode) | |
ThreadLock (LockMode lockMode, Safeness safeness) | |
int | dbgCountAcquirements (Thread thread) |
LockMode | getMode () |
Safeness | getSafeness () |
void | setSafeness (Safeness safeness) |
String | toString () |
boolean | willRelease () |
Protected Static Fields | |
static final String | noKeyHashKey = "$" |
Protected Static Methods | |
static void | insertLogables (ArrayList< Object > list, Object logable) |
Protected Methods | |
void | construct (String name, boolean doRegister) |
void | dumpStateOnLoggerRemoval () |
Domain | evaluateResultDomain (String domainPath) |
void | getAllVerbosities (Logger logger, Domain dom, Variable cfgResult) |
void | getDomainPrefixFromConfig (Domain dom) |
void | getVerbosityFromConfig (Logger logger, Domain dom, Variable variable) |
boolean | isThreadRelatedScope (Scope scope) |
void | log (Domain dom, Verbosity verbosity, Object[] logables, Inclusion prefixes) |
void | logInternal (Verbosity verbosity, String subDomain, AString logable) |
void | logStateCollectPrefixes (Domain domain, int indentSpaces, AString target) |
void | logStateDomainRecursive (Domain domain, AString buf) |
void | logStateDomainsWithDiffVerb (Domain domain, int loggerNo, ArrayList< Domain > results) |
void | setDomainImpl (String scopeDomain, Scope scope, int packageLevel, boolean removeNTRSD, Thread thread) |
void | setPrefixImpl (Object prefix, Scope scope, int packageLevel, Thread thread) |
void | verbositySettingToVariable (Domain domain, int loggerNo, Variable variable) |
void | writeVerbositiesOnLoggerRemoval (Logger logger) |
Package Access Methods | |
Domain | findDomain (Domain domainSystem, AString domainPath) |
Package Access Methods inherited from ThreadLock | |
void | constructor (LockMode lockMode, Safeness safeness) |
Lox | ( | String | name, |
boolean | doRegister | ||
) |
Constructs a new, empty Lox with the given name. The name is immutable and all Lox objects registered with ALox must be unique. Lower case letters in the name are converted to upper case. The name "Log"
is reserved for the internal default singleton used for debug-logging.
If parameter register is true
(the default), static method ALox.register is invoked and the object will be retrievable with static method ALox.get. In some situations, such 'registration' may not be wanted.
Lox | ( | String | name | ) |
Overloaded constructor providing value true
for parameter doRegister.
name | The name of the Lox. Will be converted to upper case. |
void acquire | ( | ) |
void Assert | ( | boolean | condition, |
Object... | logables | ||
) |
Logs a list of Logables only if parameter condition is not true
.
If executed, Verbosity.ERROR is used.
The first logable provided may be a domain name. All values are passed to entryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Object
[], then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method. In the C# version, where flexibility of parameter passing is limited due to the use of compiler-inserted parameters, parameters of type Object
[] can also be used to provide more than four logables.
'assert'
is a Java keyword.condition | If false , the Log Statement is executed. |
logables | The list of Logables, optionally including a domain name at the start. |
|
protected |
|
static |
Overloaded method providing default parameter null
.
|
static |
This static method creates an adequate/default console logger. Currently, there is no detection mechanism implemented in the Java implementation of ALox. This might change in the future.
Hence, unless configuration variable ALOX_CONSOLE_TYPE is set, this method creates a logger of type ConsoleLogger.
name | The name of the Logger. A value of null implies standard logger names defined in the Logger sub-classes. |
|
protected |
Implements functionality for configuration variable LOXNAME_DUMP_STATE_ON_EXIT
. Is called when a logger is removed.
void entry | ( | String | domain, |
Verbosity | verbosity, | ||
Object... | logables | ||
) |
Logs a list of Logables using the given Verbosity.
This method is usually not used directly. Instead, methods info, verbose, warning and error provide simpler interfaces.
Hence, the use of this method is recommended only if the verbosity of a log statement is is evaluated only at runtime.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The verbosity. |
logables | The objects to log. |
void entryDetectDomain | ( | Verbosity | verbosity, |
Object... | logables | ||
) |
Logs a list of Logables with the given Verbosity.
If more than one Logable is given and the first one is of string type and comprises a valid domain name, then this first argument is interpreted as a the domain name! Valid domain names are strings that consists only of characters of the following set:
'-'
) and'_'
).If a first Logable could be misinterpreted as being a domain name, an empty string (the "neutral" domain) has to be added as a first argument. Alternatively, a character which is illegal in respect to domain names could be added to the first argument, for example a simple space at the end of an output string.
verbosity | The verbosity. |
logables | The logables with optionally a detectable domain name as a first argument. |
void error | ( | Object... | logables | ) |
Logs a list of Logables using Verbosity.ERROR.
The first logable provided may be a domain name. All values are passed to entryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Object
[], then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method. In the C# version, where flexibility of parameter passing is limited due to the use of compiler-inserted parameters, parameters of type Object
[] can also be used to provide more than four logables.
logables | The list of Logables, optionally including a domain name at the start. |
|
protected |
Assembles the resulting domain from the given domainPath and the Scope Domain paths (see setDomain) according to the scope identified by scopeInfo. The resulting full domain string is assembled from inner to outer scope. If domainPath, respectively as soon as any of the scope levels' Scope Domain paths starts with the character defined in Domain.PATH_SEPARATOR, the evaluation is stopped (the path is interpreted as absolute).
domainPath | The domain path. If starting with the character defined in Domain.PATH_SEPARATOR, no Scope Domains are applied. |
Invokes Find on the given domain and logs internal message when the domain was not known before.
domainSystem | The domain system. Either the standard or the internal one. |
domainPath | The domain path. |
Reads the verbosity for the given logger and domain from the ALib configuration system. This internal method is used when a new logger is added. Walks recursively for all existing domains.
logger | The logger to set the verbosity for. |
dom | The domain to set the verbosity for. |
cfgResult | The result of the search for the variable to set verbosities from. |
|
protected |
Reads a prefix string from the ALib configuration system. This internal method is used when a new domain is created,
dom | The domain to set the verbosity for. |
Logger getLogger | ( | String | loggerName | ) |
Retrieves an instance of a Logger by its name. This might be useful when access to a Logger is needed to change its configuration.
loggerName | The name of the Logger to search for (case insensitive). |
String getName | ( | ) |
Returns the name of this Lox. The name user defined, provided in the constructor, converted to upper case and otherwise immutable.
void getState | ( | AString | buf, |
int | flags | ||
) |
This method collects state information about this lox in a formatted multi-line AString. Parameter flags is a bit field with bits defined in constants of class Lox prefixed with "STATE_INFO_", e.g. STATE_INFO_LOGGERS
.
buf | The target string. |
flags | Flag bits that define which state information is collected. |
Reads the verbosity for the given logger and domain from the ALib configuration system. This internal method is used in two occasions:
logger | The logger to set the verbosity for. |
dom | The domain to set the verbosity for. |
variable | The (already read) variable to set verbosities from. |
void If | ( | boolean | condition, |
String | domain, | ||
Verbosity | verbosity, | ||
Object... | logables | ||
) |
Logs a list of Logables only if the parameter condition is true
.
If one of the arguments (or a single argument given) is of type Object
[], then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method. In the C# version, where flexibility of parameter passing is limited due to the use of compiler-inserted parameters, parameters of type Object
[] can also be used to provide more than four logables.
'if'
is a Java keyword.void If | ( | boolean | condition, |
Verbosity | verbosity, | ||
Object... | logables | ||
) |
Logs a list of Logables only if the parameter condition is true
. This overloaded version omits parameter domain.
The first logable provided may be a domain name. All values are passed to entryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Object
[], then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method. In the C# version, where flexibility of parameter passing is limited due to the use of compiler-inserted parameters, parameters of type Object
[] can also be used to provide more than four logables.
'if'
is a Java keyword.condition | If false , the Log Statement is executed. |
verbosity | The verbosity. |
logables | The objects to log. |
void info | ( | Object... | logables | ) |
Logs a list of Logables using Verbosity.INFO.
The first logable provided may be a domain name. All values are passed to entryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Object
[], then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method. In the C# version, where flexibility of parameter passing is limited due to the use of compiler-inserted parameters, parameters of type Object
[] can also be used to provide more than four logables.
logables | The list of Logables, optionally including a domain name at the start. |
|
staticprotected |
Simple helper method that inserts a logable at the front of given list. If the logable is an object array, each object will be inserted.
list | The logable list |
logable | The logable or array of logables. |
boolean isRegistered | ( | ) |
Status of registration with ALox. To keep a Lox "private" using parameter doRegister of the constructor, allows to suppress registration. Registered instances of this class can be statically received (by their name) using ALox.get.
true
if this instance was registered with ALox, false
if not.
|
protected |
Checks if given scope is thread-related.
scope | The scope that is to be checked. |
true
if scope is thread-related, false
else. This method is looping over the Loggers, checking their verbosity against the given one, and, if they match, invoke the log method of the Logger. With the first logger identified to be active, the Prefix Objects get collected from the scope store.
dom | The domain to log on |
verbosity | The verbosity. |
logables | The objects to log. |
prefixes | Denotes if prefixes should be included or not. |
Logs an internal error message using the internal domain tree as defined in ALox.INTERNAL_DOMAINS.
verbosity | The verbosity. |
subDomain | The sub-domain of the internal domain to log into. |
logable | The message. |
Internal method used by State() to recursively (DFS) log Prefix Logables bound to Log Domains
domain | The actual domain to check. |
indentSpaces | The number of spaces to write before each line. |
target | The target string. |
Internal method used by State() to recursively log Domain instances.
domain | The Domain instance to log out. |
buf | The buffer to log to. |
|
protected |
Internal method used by State() to recursively (DFS) collect Domains of Logger that have a different verbosity than their parent.
domain | The actual domain to check. |
loggerNo | The logger to collect domains for. |
results | The result list. |
void mapThreadName | ( | String | threadName | ) |
This method sets a human readable name to the current thread which is optionally included in each log line.
threadName | The name of the thread as it should be displayed in the logs. |
void mapThreadName | ( | String | threadName, |
long | id | ||
) |
This method sets a human readable name to the given thread ID (or current thread) which is optionally included in each log line.
threadName | The name of the thread as it should be displayed in the logs. |
id | Parameter providing the thread ID. Defaults to -1 which uses the current thread. |
void once | ( | Object | logables | ) |
Overloaded version of once.
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
void once | ( | Object | logables, |
int | quantity | ||
) |
Overloaded version of once.
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
void once | ( | Object | logables, |
int | quantity, | ||
Scope | scope | ||
) |
Overloaded version of once.
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
scope | The Scope that the group or counter is bound to. |
void once | ( | Object | logables, |
int | quantity, | ||
Scope | scope, | ||
int | pkgLevel | ||
) |
Overloaded version of once.
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
scope | The Scope that the group or counter is bound to. |
pkgLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
void once | ( | Object | logables, |
int | quantity, | ||
String | group | ||
) |
Overloaded version of once.
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope.) If omitted (or empty or null), the counter is is bound to the Scope provided. If omitted and scope is Scope.Global, then the counter is associated exclusively with the single Log Statement itself. |
void once | ( | String | domain, |
Verbosity | verbosity, | ||
Object | logables | ||
) |
void once | ( | String | domain, |
Verbosity | verbosity, | ||
Object | logables, | ||
int | quantity | ||
) |
Overloaded version of once.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The Verbosity of the Log Statement (if performed). |
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Overloaded version of once.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The Verbosity of the Log Statement (if performed). |
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
scope | The Scope that the group or counter is bound to. |
Overloaded version of once.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The Verbosity of the Log Statement (if performed). |
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
scope | The Scope that the group or counter is bound to. |
pkgLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
void once | ( | String | domain, |
Verbosity | verbosity, | ||
Object | logables, | ||
Scope | scope, | ||
int | pkgLevel, | ||
int | quantity | ||
) |
Overloaded version of once.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The Verbosity of the Log Statement (if performed). |
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
scope | The Scope that the group or counter is bound to. |
pkgLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
void once | ( | String | domain, |
Verbosity | verbosity, | ||
Object | logables, | ||
String | group | ||
) |
Overloaded version of once.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The Verbosity of the Log Statement (if performed). |
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope.) If omitted (or empty or null), the counter is is bound to the Scope provided. If omitted and scope is Scope.Global, then the counter is associated exclusively with the single Log Statement itself. |
void once | ( | String | domain, |
Verbosity | verbosity, | ||
Object | logables, | ||
String | group, | ||
int | quantity | ||
) |
Overloaded version of once.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The Verbosity of the Log Statement (if performed). |
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope.) If omitted (or empty or null), the counter is is bound to the Scope provided. If omitted and scope is Scope.Global, then the counter is associated exclusively with the single Log Statement itself. |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . |
Overloaded version of once.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The Verbosity of the Log Statement (if performed). |
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope.) If omitted (or empty or null), the counter is is bound to the Scope provided. If omitted and scope is Scope.Global, then the counter is associated exclusively with the single Log Statement itself. |
scope | The Scope that the group or counter is bound to. |
void once | ( | String | domain, |
Verbosity | verbosity, | ||
Object | logables, | ||
String | group, | ||
Scope | scope, | ||
int | pkgLevel | ||
) |
Overloaded version of once.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The Verbosity of the Log Statement (if performed). |
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope.) If omitted (or empty or null), the counter is is bound to the Scope provided. If omitted and scope is Scope.Global, then the counter is associated exclusively with the single Log Statement itself. |
scope | The Scope that the group or counter is bound to. |
pkgLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
void once | ( | String | domain, |
Verbosity | verbosity, | ||
Object | logables, | ||
String | group, | ||
Scope | scope, | ||
int | pkgLevel, | ||
int | quantity | ||
) |
Logs given logables once, up to quantity times or every n-th time. In its simplest overloaded version, the counter is bound to the source code line, hence, only the first execution of this exact Log Statement is executed.
Using parameter group, a set of Log Statements that share the same group key, can be grouped and of such set, only the one which is first executed actually logs.
Alternatively, when key is omitted (or null or empty), but a Scope is given with parameter scope, then the counter is associated with the scope.
Finally, parameters key and scope can also be used in combination. The key is then unique in respect to the Scope provided.
Using, none, one or both of the parameters group and scope, among others, the following use cases can be achieved.
Object
[] may be passed with parameter logables, like in the following sample: null
respectively Verbosity.INFO
.When parameter quantity is a negative value, the log statement is executed every n-th time instead n-times. E.g, if quantity is -5
, the first statement is executed and afterwards every fifth invocation.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The Verbosity of the Log Statement (if performed). |
logables | The object(s) to log. (Multiple objects may be provided as an Object[].) |
group | The optional name of the statement group . If used, all statements that share the same group name are working on the same counter (according to the scope.) If omitted (or empty or null), the counter is is bound to the Scope provided. If omitted and scope is Scope.Global, then the counter is associated exclusively with the single Log Statement itself. |
scope | The Scope that the group or counter is bound to. |
pkgLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
quantity | The number of logs to be performed. As the name of the method indicates, this defaults to 1 . If negative, the first and every "-quantity-th" statement is executed. |
void release | ( | ) |
boolean removeLogger | ( | Logger | logger | ) |
Removes a logger from this container.
logger | The logger to be removed. |
true
, if the Logger was found and removed, false
otherwise. Logger removeLogger | ( | String | loggerName | ) |
Removes logger named loggerName from this container.
loggerName | The name of the Logger(s) to be removed (case insensitive). |
null
if not found. void removeThreadDomain | ( | String | scopeDomain, |
Scope | scope | ||
) |
Overload version providing default value for parameter thread.
scopeDomain | The domain path to register. |
scope | Either Scope.THREAD_OUTER and Scope.THREAD_INNER. With other values, an internal error is logged. |
void removeThreadDomain | ( | String | scopeDomain, |
Scope | scope, | ||
Thread | thread | ||
) |
This method is used to remove an explicitly given domain path from the list of domain paths set for Scope.THREAD_OUTER and Scope.THREAD_INNER.
To remove the most recently added domain path from such thread-related Scope, use one of the overloaded methods setDomain and provide an empty or nulled value for parameter scopeDomain (the same as how domain paths of other Scopes are removed).
scopeDomain | The domain path to register. |
scope | Either Scope.THREAD_OUTER and Scope.THREAD_INNER. With other values, an internal error is logged. |
thread | The thread to set/unset a thread-related Scope Domains for. Defaults to the current thread. |
Object retrieve | ( | ) |
Overloaded version of retrieve which omits parameters.
null
if nothing was found. Object retrieve | ( | Scope | scope | ) |
Overloaded version of retrieve which omits parameters.
scope | The Scope that the data is bound to. |
null
if nothing was found. Object retrieve | ( | Scope | scope, |
int | pkgLevel | ||
) |
Overloaded version of retrieve which omits parameters.
scope | The Scope that the data is bound to. |
pkgLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
null
if nothing was found. Object retrieve | ( | String | key | ) |
Overloaded version of retrieve which omits parameters.
key | The optional key to the data. If omitted (or empty or null ), the data is bound to the Scope provided. If omitted and scope is Scope.GLOBAL, then the data is unique to the Lox. |
null
if nothing was found. Object retrieve | ( | String | key, |
Scope | scope | ||
) |
Overloaded version of retrieve which omits parameters.
key | The optional key to the data. If omitted (or empty or null ), the data is bound to the Scope provided. If omitted and scope is Scope.GLOBAL, then the data is unique to the Lox. |
scope | The Scope that the data is bound to. |
null
if nothing was found. Object retrieve | ( | String | key, |
Scope | scope, | ||
int | pkgLevel | ||
) |
Retrieves an object which was previously stored by invoking using store. Optional parameters key and scope offer various possibilities to reference such objects.
key | The optional key to the data. If omitted (or empty or null ), the data is bound to the Scope provided. If omitted and scope is Scope.GLOBAL, then the data is unique to the Lox. |
scope | The Scope that the data is bound to. |
pkgLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
null
if nothing was found. void setDomain | ( | String | scopeDomain, |
Scope | scope | ||
) |
void setDomain | ( | String | scopeDomain, |
Scope | scope, | ||
int | packageLevel | ||
) |
The given scopeDomain becomes the default domain path for given scope. This means, that any subsequent log invocations (from within this same scope) can omit the domain parameter, or if they provide one, this Scope Domain path is prepended. If subsequent log calls specify a domain name with a leading '/' character, then the Scope Domain of the scope is ignored.
Furthermore, if the given scope is an inner scope, outer scopes are prepended to the given scopeDomain when the resulting domain of a log invocation is evaluated. Again, this behavior can be overruled by prepending a leading '/' character to scopeDomain.
To remove a previously set Scope Domain a nulled or empty string has to be passed with parameter scopeDomain.
For Scope.THREAD_OUTER and Scope.THREAD_INNER, passing an empty or nulled string removes the most recently added domain path. For removing an explicitly named domain path of Scope.THREAD_OUTER and Scope.THREAD_INNER use method removeThreadDomain.
scopeDomain | The domain path to register. |
scope | The scope that should the given domain be registered for. Available Scope definitions are platform/language dependent. |
packageLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
void setDomain | ( | String | scopeDomain, |
Scope | scope, | ||
Thread | thread | ||
) |
This overloaded version of setDomain is applicable only for Scope.THREAD_OUTER and Scope.THREAD_INNER and allows to specify the thread that the setting should be associated with.
If scopeDomain is null
or empty, the most recently added domain path is removed. For removing an explicitly named domain associated with a thread use method removeThreadDomain.
scopeDomain | The domain path to register. |
scope | Either Scope.THREAD_OUTER or Scope.THREAD_INNER. With other values, an internal error is logged. |
thread | The thread to set/unset a thread-related Scope Domains for. |
|
protected |
Implementation of the interface method fetching all possible parameters.
scopeDomain | The domain path to register. |
scope | The scope that the given domain should be registered for. Available Scope definitions are platform/language dependent. |
packageLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
removeNTRSD | Used to remove thread-related Scope Domains (and is true only when invoked by interface method removeThreadDomain. |
thread | The thread to set/unset a thread-related Scope Domain for. |
void setDomainSubstitutionRule | ( | String | domainPath, |
String | replacement | ||
) |
Adds a Domain Substitution Rule. Domain Substitution is performed as a last step when evaluating the domain path of a Log Statement, taking Scope Domains and the optional parameter domain of the statement into account.
Wildcards
Parameter domainPath supports 'wildcard' character '*'
at its beginning and at its end (or both). This allows to have four types of rules:
*
at the end of domainPath)*
at the start of domainPath)*
at both, start and the end of domainPath)Only minimal checks are performed, e.g. if an exact match is requested, but domainPath does not start with character '/'
. In this and some other cases, the rule is not stored and an internal warning is logged. Further checks, for example for illegal domain path characters are not performed (those will be eliminated when the resulting domain path is to be created internally).
Circular Dependencies
If the given rules have circular dependencies, only a limited number (ten) replacements are performed. If this number of replacements for one Log Statement is exceeded, an internal warning message is logged. This is done only once over the life-time of a Logger.
Application of Rules
Rules are applied in the order of their definition. After all rules have been applied this is repeated as long as at least one rule matched (up to ten times).
Deletion of Rules To delete a rule, invoke the method with same parameter domainPath and a 'nulled' or empty string for parameter replacement. To delete all rules, invoke the method with parameter domainPath 'nulled' or empty.
Final remarks Domain substitution is useful to permanently change ('redirect') domain paths of 3rd party code (e.g. libraries using ALox) or log statements that must not be changed for other reasons. It is advised to not 'overuse' this feature, as side effects are inherent to the concept of Domain Substitution. For example, an unwanted side effect might be that Prefix Logables are not applicable to the substituted domain, while other Prefix Logables are bound to the resulting domain.
For Lox objects that should be protected of external manipulation, it is advisable, to remove all Domain Substitution Rules right after the Lox was created by invoking this method with a nulled value for parameter domainPath. The reason is, that otherwise, through configuration files or command line parameters, domains of the Lox can be substituted and then the resulting domains Verbosities be overwritten using further configuration variables. Any prioritized 'internal' setting of Verbosities this way could be circumvented!
For more information consult the ALox User Manual.
domainPath | The path to search. Has to start with either '/' or '*' . |
replacement | The replacement path. |
void setPrefix | ( | Object | logable | ) |
Overloaded version of setPrefix providing default value Inclusion.INCLUDE
for parameter otherPLs and default value null
for parameter domain.
logable | The Prefix Logable(s) to set. |
void setPrefix | ( | Object | logable, |
String | domain | ||
) |
Overloaded version of setPrefix providing default value Inclusion.INCLUDE
for parameter otherPLs.
logable | The Prefix Logable(s) to set. |
domain | The domain path. Defaults to null , resulting in evaluated Scope Domain path. |
void setPrefix | ( | Object | prefix, |
Scope | scope | ||
) |
void setPrefix | ( | Object | prefix, |
Scope | scope, | ||
int | packageLevel | ||
) |
The given prefix becomes a Prefix Logable provided to loggers with each log statement executed within the given scope. The list of objects received by a logger is sorted from outer scope to inner scope. The logable of the Log Statement itself, is the last in the list, except one or more Prefix Logables of Scope.ThreadInner are set. Those are (similar to how this Scope is used with Scope Domains) appended to the end of the list.
To remove a previously set Prefix Logable, null
has to be passed with parameter logable. For Scope.THREAD_OUTER and Scope.THREAD_INNER, passing null
removes the most recently added Prefix Logable.
prefix | The Prefix Logable(s) to set. |
scope | The scope that should the given logable be registered for. Available Scope definitions are platform/language dependent. |
packageLevel | Used only with Scope.PACKAGE. Cuts the given number of package parts (separated with '.') from the end of the packages. Optional and defaults to 0 . |
void setPrefix | ( | Object | prefix, |
Scope | scope, | ||
Thread | thread | ||
) |
This overloaded version of setPrefix is applicable only for Scope.THREAD_OUTER and Scope.THREAD_INNER and allows to specify the thread that the setting should be associated with.
If logable is null
, the most recently added Prefix Logable is removed.
prefix | The Prefix Logable(s) to set. |
scope | Either Scope.THREAD_OUTER or Scope.THREAD_INNER. With other values, an internal error is logged. |
thread | The thread to set/unset a thread-related Prefix Logable for. |
void setPrefix | ( | Object | prefix, |
String | domain, | ||
Inclusion | otherPLs | ||
) |
The given logable becomes a Prefix Logable associated to the given Log Domain. Prefix Logables associated with the Log Domain are added to the list of Logables right before the main Logable of the Log Statement itself. Multiple Prefix Logables can be added per Log Domain.
To remove the most recently added Prefix Logable associated with a Log Domain, null
has to be passed with parameter logable.
""
which addresses the domain evaluated for the current scope.prefix | The Prefix Logable(s) to set. |
domain | The domain path. Defaults to null , resulting in evaluated Scope Domain path. |
otherPLs | If set to Inclusion.Exclude , scope-related Prefix Logables are ignored and only domain-related Prefix Logables are passed to the Loggers. Defaults to Inclusion.Include . |
|
protected |
Implementation of the interface method fetching all possible parameters.
prefix | The Prefix Logable(s) to set. |
scope | The scope that the given logable should be registered for. Available Scope definitions are platform/language dependent. |
packageLevel | Used only with Scope.PACKAGE. Cuts the given number of package parts (separated with '.') from the end of the packages. Optional and defaults to 0 . |
thread | The thread to set/unset a thread-related Prefix Logable for. |
void setStartTime | ( | ) |
Overloaded version of setStartTime( Date, String ) providing default values null
for parameters startTime and loggerName.
void setStartTime | ( | Date | startTime | ) |
Overloaded version of setStartTime( Date, String ) providing default value null
for parameter loggerName.
startTime | Optional parameter with the new start time. Defaults to DateTime.Now if omitted. |
void setStartTime | ( | Date | startTime, |
String | loggerName | ||
) |
This method is used reset (or to explicitly set) the start time of the Logger(s). The only impact is the output of time differences in the log lines. Hence, it is useful to see some absolute time values when doing basic performance tests using the Logger.
startTime | Optional parameter with the new start time. Defaults to current time if omitted. |
loggerName | The name of the Logger(s) whose start time is to be set (case insensitive). Defaults to empty string, which indicates that all loggers are to be affected. |
Overloaded version of setVerbosity providing
PRIO_SOURCE
for parameter priority and '/'
for parameter domain.logger | The logger to be to be affected. |
verbosity | The 'level of verboseness' to be set. |
Overloaded version of setVerbosity providing default value PRIO_SOURCE
for parameter priority.
logger | The logger to be to be affected. |
verbosity | The 'level of verboseness' to be set. |
domain | The parent (start) domain to be set. The use of absolute paths starting with '/' are recommended. Defaults to root domain "/". |
Sets the Verbosity of the Log Domain which is evaluated from parameter domain and applicable Scope Domains. The verbosity given, is set recursively for all sub-domains.
With the first invocation of this method for a distinct logger, this Logger is registered with this Lox. In this case, prior to setting the given Verbosity for the evaluated sub-domain, the Verbosity for all domains is set to Verbosity.Off.
To deregister a Logger with a Lox, use method removeLogger. To 'disable' a Logger, invoke this method with parameters verbosity equaling to Verbosity.Off and domain to "/"
.
Optional parameter priority defaults to Configuration.PRIO_DEFAULT_VALUES, which is a lower priority than those of the standard plug-ins of external configuration data. Therefore, external configuration by default 'overwrite' settings made from 'within the source code', which simply means by invoking this method.
The parameter can be provided for two main reasons:
PRIO_DEFAULT_VALUES + 1
, then this sub-domain will not be affected by future invocations of this method with standard-priority given.For more information on how to use external configuration variables with priority and on protecting verbosity settings, consult the ALox User Manual.
'/'
, which suppresses the concatenation of Scope Domains. '/'
, while with other methods of this class, it defaults to an empty string.logger | The logger to be to be affected (case insensitive). |
verbosity | The 'level of verboseness' to be set. |
domain | The parent (start) domain to be set. The use of absolute paths starting with '/' are recommended. Defaults to root domain "/". |
priority | The priority of the setting. Defaults to Configuration.PRIO_DEFAULT_VALUES. |
void setVerbosity | ( | String | loggerName, |
Verbosity | verbosity | ||
) |
Overloaded version of setVerbosity providing
PRIO_SOURCE
for parameter priority and '/'
for parameter domain.loggerName | The logger to be to be affected, identified by its name (case insensitive). |
verbosity | The 'level of verboseness' to be set. |
void setVerbosity | ( | String | loggerName, |
Verbosity | verbosity, | ||
String | domain | ||
) |
Overloaded version of setVerbosity providing default value PRIO_SOURCE
for parameter priority.
loggerName | The logger to be to be affected, identified by its name (case insensitive). |
verbosity | The 'level of verboseness' to be set. |
domain | The parent (start) domain to be set. The use of absolute paths starting with '/' are recommended. Defaults to root domain "/". |
void setVerbosity | ( | String | loggerName, |
Verbosity | verbosity, | ||
String | domain, | ||
int | priority | ||
) |
Same as setVerbosity but addressing the Logger to manipulate by its name.
This method may only be used after a Logger was once 'registered' with this Lox using setVerbosity.
loggerName | The logger to be to be affected, identified by its name (case insensitive). |
verbosity | The 'level of verboseness' to be set. |
domain | The parent (start) domain to be set. The use of absolute paths starting with '/' are recommended. Defaults to root domain "/". |
priority | The priority of the setting. Defaults to Configuration.PRIO_DEFAULT_VALUES. |
void state | ( | String | domain, |
Verbosity | verbosity, | ||
String | headLine | ||
) |
void state | ( | String | domain, |
Verbosity | verbosity, | ||
String | headLine, | ||
int | flags | ||
) |
This method logs the current configuration of this Lox and its encapsulated objects. It uses method getState to assemble the logable string.
domain | Optional Log Domain which is combined with Scope Domains set for the Scope of invocation. |
verbosity | The verbosity. |
headLine | If given, a separated headline will be logged at first place. |
flags | Flag bits that define which state information is logged. |
void store | ( | Object | data | ) |
Overloaded version of store providing default parameters.
data | The data object to store. If null , currently stored data will be removed. |
void store | ( | Object | data, |
Scope | scope | ||
) |
Overloaded version of store providing default parameters.
data | The data object to store. If null , currently stored data will be removed. |
scope | The Scope that the data is bound to. |
void store | ( | Object | data, |
Scope | scope, | ||
int | pkgLevel | ||
) |
Overloaded version of store providing default parameters.
data | The data object to store. If null , currently stored data will be removed. |
scope | The Scope that the data is bound to. |
pkgLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
void store | ( | Object | data, |
String | key | ||
) |
Overloaded version of store providing default parameters.
data | The data object to store. If null , currently stored data will be removed. |
key | The optional key to the data. If omitted (or empty or null ), the data is bound to the Scope provided. If omitted and scope is Scope.GLOBAL, then the data is unique to the Lox. |
void store | ( | Object | data, |
String | key, | ||
Scope | scope | ||
) |
Overloaded version of store providing default parameters.
data | The data object to store. If null , currently stored data will be removed. |
key | The optional key to the data. If omitted (or empty or null ), the data is bound to the Scope provided. If omitted and scope is Scope.GLOBAL, then the data is unique to the Lox. |
scope | The Scope that the data is bound to. |
void store | ( | Object | data, |
String | key, | ||
Scope | scope, | ||
int | pkgLevel | ||
) |
Stores an object which can afterwards be retrieved by invoking retrieve. Optional parameters key and scope offer various possibilities to reference this data later.
To remove data from the store, pass null
with parameter data.
new
) may be passed!data | The data object to store. If null , currently stored data will be removed. |
key | The optional key to the data. If omitted (or empty or null ), the data is bound to the Scope provided. If omitted and scope is Scope.GLOBAL, then the data is unique to the Lox. |
scope | The Scope that the data is bound to. |
pkgLevel | Used only if parameter scope equals Scope.PACKAGE to reference parent packages. Optional and defaults to 0 . |
void verbose | ( | Object... | logables | ) |
Logs a list of Logables using Verbosity.VERBOSE.
The first logable provided may be a domain name. All values are passed to entryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Object
[], then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method. In the C# version, where flexibility of parameter passing is limited due to the use of compiler-inserted parameters, parameters of type Object
[] can also be used to provide more than four logables.
logables | The list of Logables, optionally including a domain name at the start. |
Helper method of dumpStateOnLoggerRemoval to recursively collect domain settings.
domain | The actual domain. |
loggerNo | The number of the logger |
variable | The AString to collect the information. |
void warning | ( | Object... | logables | ) |
Logs a list of Logables using Verbosity.WARNING.
The first logable provided may be a domain name. All values are passed to entryDetectDomain. See documentation of this method for information on how to avoid ambiguities in respect to domain names.
If one of the arguments (or a single argument given) is of type Object
[], then the contents of this list is inserted into the list of logables. This allows to collect logables prior to invoking the method. In the C# version, where flexibility of parameter passing is limited due to the use of compiler-inserted parameters, parameters of type Object
[] can also be used to provide more than four logables.
logables | The list of Logables, optionally including a domain name at the start. |
|
protected |
Implements functionality for configuration variable LOXNAME_LOGGERNAME_VERBOSITY
. Is called when a logger is removed.
logger | The logger to write the verbosity for. |
|
protected |
A temporary object following the "create once and reuse" design pattern.
int cntLogCalls = 0 |
A counter for the quantity of calls. The count includes logs that were suppressed by disabled Log Domain and those suppressed by the optional log condition parameter.
|
protected |
The root domain "/". All registered domains become a sub domain of this root. If a Sub-Log Domains' Verbosity is not explicitly set, such sub domain inherits the verbosity of its parent.
|
protected |
The list of domain substitution rules.
A temporary AString, following the "create once and reuse" design pattern.
|
protected |
A list of lists of objects. The list is passed to the Loggers. For each recursive call, one list is created.
|
protected |
Flag used with configuration variable LOXNAME_DUMP_STATE_ON_EXIT.
|
protected |
Used for tabular output of logger lists
|
protected |
Used for tabular output of logger lists
|
staticprotected |
A key value used in stores if no key is given (global object).
Vector<String> omittablePackagePrefixes |
A list of prefixes of 'packages.classes.methods' on the stack that are ignored when identifying the scope info. Usually this contains "com.aworx.lox" and "com.aworx.lib" and there is no need to change this.
|
protected |
Flag if a warning on circular rule detection was logged.
The resulting domain name for internal logs.
|
protected |
Scope Domains .
|
protected |
Information about the source code, method, thread, etc. invoking a log call
|
protected |
Log Data
|
protected |
Log once counters
|
protected |
Prefix logables store
Temporary string used with domain substitutions.
Temporary string used with domain substitutions.