This package (primarily) contains types representing the core concepts of the Livy logger. Those are especially useful when you're building Livy components using TypeScript. For this reason, code blocks in this documentation are written in TypeScript.
Table of Contents:
This module contains the available log levels and their corresponding severities:
LogLevelis a type representing any valid RFC 5424 log level while
logLevelsis an array containing all those level strings, sorted from least (
debug) to most serious (
SeverityLeveltype represents log level severity as an integer from
SeverityMapobject maps log levels to their corresponding severity (
debug → 7, ..., emergency → 0):/*** Sort a list of log levels by severity ("debug" first, "emergency" last)*/
LogRecord interface which describes the structure of a Livy log record. This is useful for writing, for example, a custom formatter in TypeScript:
Describes the abstract structure of a Livy logger instance (
LoggerInterface) as well as two variations,
SyncLoggerInterface, which extend
LoggerInterface and additionally define concrete return types (instead of
unknown) for the log methods.
Describes the minimum viable structure of a Livy handler as
HandlerInterface. Additionally, a
SyncHandlerInterface is provided which represents a handler that has synchronous logging methods in addition to the asynchronous ones.
Describes the structure of a resettable handler or processor — a component able to reset its internal state (e.g. the
ArrayHandler which can clear its own buffer).
Handlers implementing this interface expose a
reset method to trigger the reset:
const resettableHandler =resettableHandler
Calling this method on a handler should not only reset its own state but also the state of all components attached to it (e.g. processors or wrapped handlers).
Describes the structure of a handler which has a configurable formatter.
Describes the structure of a handler with support for processors.
Handlers implementing this interface expose a Set of processors as their
const processableHandler =processableHandlerprocessors
Describes the structure of a handler which wants to do cleanup tasks when the process exits.
If you want to implement such a handler, please be aware that there is often no spare time left when the
close() method is invoked (because it is triggered when the process exits/the web page is left), i.e. asynchronous cleanup actions usually won't work.
Describes the structure of a formatter.
Describes the structure of a processor.
A processor can either be stateless or stateful:
A stateless processor is just a bare function taking a log record and returning a log record.
A stateful processor is a class with a
process method. That method then does the job of accepting and returning a log record.
Writing a processor in a stateful is usually done...
- ...if it needs to take options (which are usually taken to the processor's constructor).
- ...if it needs to retain state between several processed records.