@barry-rocks/sdk/logging/edge
The logger for code that runs on an edge runtime such as Cloudflare Workers,
where Node’s file and process APIs aren’t available. It exposes
createWorkerLogger with the same log shape as the Node logger.
import { … } from "@barry-rocks/sdk/logging/edge";Interfaces
Section titled “Interfaces”CloudflareExecutionContext
Section titled “CloudflareExecutionContext”Methods
Section titled “Methods”passThroughOnException()
Section titled “passThroughOnException()”passThroughOnException():
void
Returns
Section titled “Returns”void
waitUntil()
Section titled “waitUntil()”waitUntil(
promise):void
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
promise |
Promise<unknown> |
Returns
Section titled “Returns”void
WorkerLoggerEnv
Section titled “WorkerLoggerEnv”Indexable
Section titled “Indexable”[
binding:string]:unknown
WorkerLoggerOptions
Section titled “WorkerLoggerOptions”Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
ctx? |
CloudflareExecutionContext |
ExecutionContext — a remote sink would flush through waitUntil. |
env? |
WorkerLoggerEnv |
Worker env bindings. |
Functions
Section titled “Functions”createWorkerLogger()
Section titled “createWorkerLogger()”createWorkerLogger(
service,options?,baseContext?):Logger
Create a logger for a Cloudflare Worker.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
service |
string |
options |
WorkerLoggerOptions |
baseContext |
LogContext |
Returns
Section titled “Returns”Example
Section titled “Example”import { createWorkerLogger } from "./emit-edge.js";
export default { async fetch(request: Request, env: Env, ctx: ExecutionContext) { const log = createWorkerLogger("artifacts", { env, ctx }); log.info("request.start", { path: new URL(request.url).pathname }); await log.flush(); return response; }};References
Section titled “References”LogContext
Section titled “LogContext”Re-exports LogContext
Logger
Section titled “Logger”Re-exports Logger
LogLevel
Section titled “LogLevel”Re-exports LogLevel