Documentation ¶
Overview ¶
Package apexorc provides a handler for logging via github.com/apex/log to an ORC file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCriticalRotationError ¶
IsCriticalRotationError returns true if the error passed to it is a CriticalRotationErorr.
Types ¶
type ArchiveFunc ¶
ArchiveFunc is a function type that is used to move an ORC log file from its current path to another location as part of the log rotation process. The function will be called with the path of the current log file, it is the responsibility of an implementation to ensure that files are moved non-destructively, but the RotatingHandler guarantees that the file will be closed before an ArchvieFunc is called, and that no attemp to log will be made until after it has completed its work.
type CloserHandler ¶
CloserHandler is a specialisation of the github.com/apex/log.Handler interface to support a Close function.
type CriticalRotationError ¶
type CriticalRotationError struct {
// contains filtered or unexported fields
}
CriticalRotationError is a special kind of error that can be returned by the Rotate() function of a RotatingHandler. Should you encounter a CriticalRotationError you should assume that logging is no longer working and decide how to proceed.
You can check an error to see if it is a CriticalRotationError by passing it to IsCriticalRotationError:
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler complies with the github.com/apex/log.Handler interface and can be passed to github.com/apex/log.SetHandler
func NewHandler ¶
NewHandler returns a Handler which can log to an ORC file at the provided path.
type RotatingHandler ¶
type RotatingHandler struct {
// contains filtered or unexported fields
}
RotatingHandler is a github.com/apex/log.Handler implementation that uses a subordinate Handler to log to an ORC file, but additionally supports on demand rotation of this file via a Rotate function. The RotatingHandler should only ever be constructed using the NewRotatingHandler function.
func NewRotatingHandler ¶
func NewRotatingHandler(path string, archiveF ArchiveFunc) (*RotatingHandler, error)
NewRotatingHandler returns an instance of the RotatingHandler with a subordinate ORC Handler logging to the provided path. Should Rotate be called then the provided ArchiveFunc will be used to move the current ORC log file out of the way before creating a new one at the same path and continuing to handle log entries.
func (*RotatingHandler) EnableAlwaysRemoveTempFiles ¶
func (h *RotatingHandler) EnableAlwaysRemoveTempFiles()
EnableAlwaysRemoveTempFiles ensures that we always remove temp files even if we were unable to convert to ORC
func (*RotatingHandler) HandleLog ¶
func (h *RotatingHandler) HandleLog(e *log.Entry) error
HandleLog passes logging duty through to the subordinate ORC Handler.
func (*RotatingHandler) Rotate ¶
func (h *RotatingHandler) Rotate() error
Rotate is a blocking call and will not return until an ORC file has been created. Logging will only be blocked for the earliest part of the process, but subsequent calls to Rotate will not complete until earlier ones have already completed.
The caller should check any returned error using IsCriticalRotationError. If a CriticalRotationError is returned, logging will no longer work as the handler will not be unlocked. It is the callers responsiblity to decide on a course of action at that point (when all else fails, panic).