Package org.agrona.concurrent.errors
Class LoggingErrorHandler
- java.lang.Object
-
- org.agrona.concurrent.errors.LoggingErrorHandler
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,ErrorHandler
public class LoggingErrorHandler extends java.lang.Object implements ErrorHandler, java.lang.AutoCloseable
A loggingErrorHandler
that records to aDistinctErrorLog
and if the log is full then overflows to aPrintStream
. If closed then error will be sent toerrorOverflow()
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.PrintStream
errorOverflow
private boolean
isClosed
private DistinctErrorLog
log
-
Constructor Summary
Constructors Constructor Description LoggingErrorHandler(DistinctErrorLog log)
Construct error handler wrapping aDistinctErrorLog
with a default ofSystem.err
for theerrorOverflow()
.LoggingErrorHandler(DistinctErrorLog log, java.io.PrintStream errorOverflow)
Construct error handler wrapping aDistinctErrorLog
andPrintStream
for error overflow.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close error handler so that is does not attempt to write to underlying storage which may be unmapped.DistinctErrorLog
distinctErrorLog()
The wrapped log.java.io.PrintStream
errorOverflow()
The wrappedPrintStream
for error log overflow when the log is full.boolean
isClosed()
Is thisLoggingErrorHandler
closed.void
onError(java.lang.Throwable throwable)
Callback to notify of an error that has occurred when processing an operation or event.
-
-
-
Field Detail
-
isClosed
private volatile boolean isClosed
-
log
private final DistinctErrorLog log
-
errorOverflow
private final java.io.PrintStream errorOverflow
-
-
Constructor Detail
-
LoggingErrorHandler
public LoggingErrorHandler(DistinctErrorLog log)
Construct error handler wrapping aDistinctErrorLog
with a default ofSystem.err
for theerrorOverflow()
.- Parameters:
log
- to wrap.
-
LoggingErrorHandler
public LoggingErrorHandler(DistinctErrorLog log, java.io.PrintStream errorOverflow)
Construct error handler wrapping aDistinctErrorLog
andPrintStream
for error overflow.- Parameters:
log
- to wrap.errorOverflow
- to be used if the log fills.
-
-
Method Detail
-
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 interfacejava.lang.AutoCloseable
-
isClosed
public boolean isClosed()
Is thisLoggingErrorHandler
closed.- Returns:
- true if
close()
has been called otherwise false.
-
distinctErrorLog
public DistinctErrorLog distinctErrorLog()
The wrapped log.- Returns:
- the wrapped log.
-
errorOverflow
public java.io.PrintStream 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
public void onError(java.lang.Throwable throwable)
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.
-
-