Class LoggerUtility
java.lang.Object
org.refcodes.logger.LoggerUtility
The Class LoggerUtility.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <L extends TrimLogger<T>, T>
voidclearLogs(Collection<L> aLoggers) Functionality to address multipleTrimLoggerinstances to clear the providedTrimLoggerinstances (multi-threaded).static <L extends TrimLogger<T>, T>
voiddeleteLogs(Criteria aCriteria, Collection<L> aLoggers) Functionality to query multipleTrimLoggerinstances with the same query to delete log lines from the providedTrimLoggerinstances (multi-threaded).static <L extends QueryLogger<T>, T>
Records<T> findLogs(Criteria aCriteria, Header<T> aHeader, int aLimit, Collection<L> aLoggers, InvocationStrategy aRecordServeStrategy) Functionality to query multipleQueryLoggerinstances with the same query and returning a single compositeRecordsinstance containing allRecordinstances returned by the queriedQueryLoggerinstances (multi-threaded).static StringgetSchemaName(String aSchemaBody, int aIndex) Required to create a schema name for aLoggerbeing part of a compositeLogger(or its sub-types) and which is being created by aLoggerFactory.static StringgetSchemaName(String aSchemaPrefix, String aSchemaSuffix) Required to create a schema name for aLoggerbeing part of a partedLogger(or its sub-types) and which is being created by aLoggerFactory.
-
Method Details
-
getSchemaName
Required to create a schema name for aLoggerbeing part of a compositeLogger(or its sub-types) and which is being created by aLoggerFactory.- Parameters:
aSchemaBody- The body part of the schema name.aIndex- The index number of the encapsulatedLoggerin question.- Returns:
- The schema name created in a uniform way.
-
getSchemaName
Required to create a schema name for aLoggerbeing part of a partedLogger(or its sub-types) and which is being created by aLoggerFactory.- Parameters:
aSchemaPrefix- The prefix part of the schema name.aSchemaSuffix- The suffix part of the schema name.- Returns:
- The schema name created in a uniform way.
-
findLogs
public static <L extends QueryLogger<T>, T> Records<T> findLogs(Criteria aCriteria, Header<T> aHeader, int aLimit, Collection<L> aLoggers, InvocationStrategy aRecordServeStrategy) throws BadCriteriaException Functionality to query multipleQueryLoggerinstances with the same query and returning a single compositeRecordsinstance containing allRecordinstances returned by the queriedQueryLoggerinstances (multi-threaded). This functionality is in common for both composite as well as partedQueryLogger(or its sub-classes) instances.- Type Parameters:
L- TheLoggertype to be used.T- The type of theRecordinstances managed by theLogger.- Parameters:
aCriteria- The query for querying the providesQueryLogger(or sub-classes).aHeader- TheHeaderspecifying theHeaderto be contained in the result.aLimit- The maximum number of elements to be returned by each individual logger. Question: To avoid a quick and dirty solution for this parameter to specify the number of elements in the result, some strategy is to be applied to querying the encapsulatedQueryLoggerinstances, just dividing the limit by the number of encapsulatedQueryLoggerinstances will often enough result in too few elements in the result. A memory wasting approach would be to pass the limit to theRecordsComposite, which stops serving elements when the limit is reached :-(aLoggers- TheQueryLoggerinstances (or its sub-types) which are to be queried.aRecordServeStrategy- The strategy with which to serve theRecordinstances in the returnedRecordsinstance, meaning which encapsulatedQueryLogger's result is to be served next upon theIterator.next()invocation. TheInvocationStrategy.ROUND_ROBINis proposed as of timeouts and "forgotten" results in case one of theQueryLogger's result is fetched too late (this depends on how long the underlying physical data sink provides for the result).- Returns:
- A
Recordsinstance containing all the foundRecordinstances. - Throws:
BadCriteriaException- thrown in case of problems related to someCriteria.
-
deleteLogs
public static <L extends TrimLogger<T>, T> void deleteLogs(Criteria aCriteria, Collection<L> aLoggers) throws BadCriteriaException Functionality to query multipleTrimLoggerinstances with the same query to delete log lines from the providedTrimLoggerinstances (multi-threaded).- Type Parameters:
L- TheLoggertype to be used.T- The type of theRecordinstances managed by theLogger.- Parameters:
aCriteria- TheCriteriato be used when querying theTrimLoggerinstances.aLoggers- TheTrimLoggerinstances (or its sub-types) which are to be queried.- Throws:
BadCriteriaException- thrown in case of problems related to someCriteria.
-
clearLogs
Functionality to address multipleTrimLoggerinstances to clear the providedTrimLoggerinstances (multi-threaded).- Type Parameters:
L- TheLoggertype to be used.T- The type of theRecordinstances managed by theLogger.- Parameters:
aLoggers- TheTrimLoggerinstances (or its sub-types) which are to be used.
-