LoggerTransport
class LoggerTransport extends FlareBaseAbstract base class for all Flare log transports.
A transport is an outbound destination that receives fully assembled LogRecord objects from the logger and decides what to do with them: format, serialize, transmit.
Extends FlareBase so transports can declare static deps and access this.config().
Transports are managed by the logger, not the host singleton lifecycle directly. Their
onStart and onStop hooks are called by the logger during its own lifecycle.
Declare a static transportName property matching the key used in flare.json under
log.transports for per-transport level filtering.
How you get one
Section titled “How you get one”new LoggerTransport()
Constructor
Section titled “Constructor”new LoggerTransport(): LoggerTransportProperties
Section titled “Properties”config
Section titled “config”config: readonly ConfigToken<unknown>[]Declares the config tokens this class requires.
Parallel to static deps. When declared, this.config(token) validates that
the token is in this array before resolving, identical to how this.inject(token)
validates static deps.
deps: never[]Declares the service tokens this class is allowed to inject().
Tokens not listed here cause inject() to throw at the call site, naming both
the class and the offending token.
transportName
Section titled “transportName”transportName: stringMethods
Section titled “Methods”config()
Section titled “config()”config<T>(token: ConfigToken<T>): TResolves a typed config section by token.
Mirrors inject() + static deps: the class must declare a static config
array, and the requested token must appear in it. Both checks throw a
developer-facing error when violated.
token ConfigToken<T>
returns T
Example:
class DbService extends FlareService { static config = [DbConfig];
async onStart() { const { url } = this.config(DbConfig); }}Throws:
When the class has no static config declaration.
Throws:
When the token is not present in static config.
inject()
Section titled “inject()”inject<T extends FlareService>(token: ServiceToken<T>): TAlways throws: transports cannot inject services; use onStart() and this.config().
token ServiceToken<T>
returns T
onStart()
Section titled “onStart()”onStart(): void | Promise<void>returns void | Promise<void>
onStop()
Section titled “onStop()”onStop(): void | Promise<void>returns void | Promise<void>
write()
Section titled “write()”write(record: LogRecord): voidReceives one fully assembled record; the transport decides how to format and emit it.
record LogRecord
Learn: Custom transports