import { Context, ILogLevel, ILogtailLog } from "@logtail/types"; import type { ExecutionContext } from "@cloudflare/workers-types"; import { Edge } from "./edge"; // Types type Message = string | Error; export class EdgeWithExecutionContext { public readonly logger: Edge; public readonly ctx: ExecutionContext; public constructor(logger: Edge, ctx: ExecutionContext) { this.logger = logger; this.ctx = ctx; } public async log( message: string | Error, level?: ILogLevel, context: any = {} as TContext, ): Promise { return this.logger.log(message, level, context, this.ctx); } public async debug( message: Message, context: TContext = {} as TContext, ): Promise { return this.logger.debug(message, context, this.ctx); } public async info( message: Message, context: TContext = {} as TContext, ): Promise { return this.logger.info(message, context, this.ctx); } public async warn( message: Message, context: TContext = {} as TContext, ): Promise { return this.logger.warn(message, context, this.ctx); } public async error( message: Message, context: TContext = {} as TContext, ): Promise { return this.logger.error(message, context, this.ctx); } }