CfLoggerTransport
class CfLoggerTransport extends LoggerTransportAbstract base for log transports running under CfLogger.
Narrows onStart and onStop to synchronous return types so the Cloudflare logger
can drive lifecycle without awaiting promises. An async override still typechecks
(TS treats a Promise return as assignable to void) but its promise is never awaited:
overrides must complete synchronously.
How you get one
Section titled “How you get one”new CfLoggerTransport()
Constructor
Section titled “Constructor”new CfLoggerTransport(): CfLoggerTransportProperties
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(): voidonStop()
Section titled “onStop()”onStop(): voidwrite()
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