Package org.agrona.concurrent.errors
Class LoggingErrorHandler
java.lang.Object
org.agrona.concurrent.errors.LoggingErrorHandler
- All Implemented Interfaces:
AutoCloseable
,ErrorHandler
A logging
ErrorHandler
that records to a DistinctErrorLog
and if the log is full then overflows
to a PrintStream
. If closed then error will be sent to errorOverflow()
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PrintStream
private boolean
private final DistinctErrorLog
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct error handler wrapping aDistinctErrorLog
with a default ofSystem.err
for theerrorOverflow()
.LoggingErrorHandler
(DistinctErrorLog log, PrintStream errorOverflow) Construct error handler wrapping aDistinctErrorLog
andPrintStream
for error overflow. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close error handler so that is does not attempt to write to underlying storage which may be unmapped.The wrapped log.The wrappedPrintStream
for error log overflow when the log is full.boolean
isClosed()
Is thisLoggingErrorHandler
closed.void
Callback to notify of an error that has occurred when processing an operation or event.
-
Field Details
-
isClosed
private volatile boolean isClosed -
log
-
errorOverflow
-
-
Constructor Details
-
LoggingErrorHandler
Construct error handler wrapping aDistinctErrorLog
with a default ofSystem.err
for theerrorOverflow()
.- Parameters:
log
- to wrap.
-
LoggingErrorHandler
Construct error handler wrapping aDistinctErrorLog
andPrintStream
for error overflow.- Parameters:
log
- to wrap.errorOverflow
- to be used if the log fills.
-
-
Method Details
-
close
public void close()Close error handler so that is does not attempt to write to underlying storage which may be unmapped.- Specified by:
close
in interfaceAutoCloseable
-
isClosed
public boolean isClosed()Is thisLoggingErrorHandler
closed.- Returns:
- true if
close()
has been called otherwise false.
-
distinctErrorLog
The wrapped log.- Returns:
- the wrapped log.
-
errorOverflow
The wrappedPrintStream
for error log overflow when the log is full.- Returns:
- wrapped
PrintStream
for error log overflow when the log is full.
-
onError
Callback to notify of an error that has occurred when processing an operation or event.This method is assumed non-throwing, so rethrowing the exception or triggering further exceptions would be a bug.
- Specified by:
onError
in interfaceErrorHandler
- Parameters:
throwable
- that occurred while processing an operation or event.
-