Skip to content

Implement context.log with Fastly logger multiplexing and Cloudflare tail workers #79

@trieloff

Description

@trieloff

Background

Per PR #77 and this comment, context.log must be implemented in the edge adapters.

Requirements

Configuration

  • context.attributes.loggers = ['target1', 'target2'] - array of log targets

Fastly Implementation

  • Use fastly:logger with multiplexing to all configured loggers
  • Automated enrichment based on context (requestId, functionName, region, etc.)
  • Support both structured (objects) and plain strings (converted to { message } objects)

Cloudflare Implementation

  • Use tail workers - one tail worker per log target
  • Ensure same log structure as Fastly
  • Support both structured (objects) and plain strings (converted to { message } objects)

API

// Structured logging
context.log.info({ user_id: 123, action: 'login' });

// Plain string logging  
context.log.error('Request failed');
// becomes: { message: 'Request failed' }

Current State

Both adapters currently use plain console.log() with no unified logging interface. The context object has no log property.

Fastly adapter: src/template/fastly-adapter.js
Cloudflare adapter: src/template/cloudflare-adapter.js

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions