Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
cloudflare avatar

Logging

  • 18 installs
  • 1.1k repo stars
  • Updated August 4, 2026
  • cloudflare/sandbox-sdk

logging adds constructor-injected structured logs across Sandbox SDK code.

About

The logging skill documents explicit constructor injection of Logger from @repo/shared across Sandbox SDK services with no global ambient logger. Child loggers via logger.child attach structured operation context at unit-of-work boundaries instead of repeating fields per call. Configuration uses SANDBOX_LOG_LEVEL debug info warn error and SANDBOX_LOG_FORMAT json or pretty read once at startup, preferring json in production and pretty locally. Tests use createNoOpLogger to avoid noise. Guidance sets info for lifecycle events, debug for tracing, warn for recoverable anomalies, and error with err object for caller-facing failures using structured second-argument context rather than string interpolation.

  • Uses constructor-injected Logger without global loggers.
  • Creates child loggers at operation boundaries.
  • Configures SANDBOX_LOG_LEVEL and SANDBOX_LOG_FORMAT env vars.
  • Silences logs in tests via createNoOpLogger.
  • Defines level guidance for lifecycle, trace, warn, and error.

Logging by the numbers

  • 18 all-time installs (skills.sh)
  • Ranked #403 of 596 Debugging skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

logging capabilities & compatibility

Capabilities
explicit constructor injection pattern · child logger boundary guidance · when adding logs level table
Works with
cloudflare
Use cases
debugging · devops
Platforms
macOS · Linux
From the docs

What logging says it does

Loggers are passed explicitly via constructor injection throughout the codebase
SKILL.md
There is no global/ambient logger
SKILL.md
npx skills add https://github.com/cloudflare/sandbox-sdk --skill logging

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs18
repo stars1.1k
Last updatedAugust 4, 2026
Repositorycloudflare/sandbox-sdk

How should I log in the Cloudflare sandbox SDK?

Add structured logging to Sandbox SDK services via constructor-injected Logger patterns.

Who is it for?

Contributors adding logs or debugging Sandbox SDK services.

Skip if: Skip for unrelated apps without @repo/shared Logger types.

When should I use this skill?

User adds logging, debug output, or Logger mocks in sandbox-sdk.

What you get

Consistent Logger injection, child contexts, and level conventions.

Files

SKILL.mdMarkdownGitHub ↗

Logging

Pattern: Explicit Constructor Injection

Loggers are passed explicitly via constructor injection throughout the codebase. There is no global/ambient logger.

import type { Logger } from '@repo/shared';

class MyService {
  constructor(private logger: Logger) {}

  async doWork(context: WorkContext) {
    const childLogger = this.logger.child({ operation: 'work' });
    childLogger.info('Working', { context });
  }
}

Child loggers

Use logger.child({ ... }) to attach structured context that will appear on every log line from that child. Prefer child loggers at the boundary of a unit of work (request, operation, session) rather than re-passing context on every call.

Configuration

Two environment variables, both read once at startup:

VarValuesPurpose
SANDBOX_LOG_LEVELdebug \info \
SANDBOX_LOG_FORMATjson \pretty

Use json in production (machine-parseable) and pretty for local dev.

In Tests

Use createNoOpLogger() from @repo/shared to silence logging in tests:

import { createNoOpLogger } from '@repo/shared';

const service = new MyService(createNoOpLogger());

Don't construct real loggers in unit tests — they add noise and can mask real failures with log output.

When Adding Logs

  • Log at info for significant lifecycle events (operation started/completed)
  • Log at debug for fine-grained tracing (request bodies, intermediate state)
  • Log at warn for recoverable anomalies
  • Log at error for failures that surface to the caller; include the error object as structured context: logger.error('Failed', { err })
  • Pass structured context as the second argument, not via string interpolation

Related skills

FAQ

What does logging do?

logging adds constructor-injected structured logs across Sandbox SDK code.

When should I use logging?

User adds logging, debug output, or Logger mocks in sandbox-sdk.

Is this skill safe to install?

Review the Security Audits panel on this page before installing in production.

Debuggingmonitoring

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.