/walkeros:walkeros-using-loggerfrom walkeros
Provides standard logging patterns for walkerOS sources and destinations, replacing console.log with scoped, level-aware logging. Covers DRY principles, when to log, and migration patterns.
Ships in walkeros. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The logger is walkerOS's standard logging system, available in all sources and
destinations via env.logger or logger parameter. It provides scoped,
level-aware logging that replaces console.log.
Core principle: Don't log what the collector already logs, and never log a
failure yourself. A step reports a failure by throwing a StepError; the
collector writes the one ERROR line per cause. Log only meaningful operations
like external API calls and transformations, at debug.
export const sourceFetch: Source.Init<Types> = async (context) => {
const { env } = context; // env.logger is available here
// Logger is scoped automatically by collector: [type:sourceId]
env.logger.info('Server listening on port 3000');
// ... build and return the source instance
};
export const destinationDataManager: DestinationInterface = {
async init({ config, env, logger }) {
// logger parameter is scoped automatically: [datamanager]
logger.debug('Auth client created');
},
async push(event, { config, data, env, logger }) {
// logger parameter is scoped: [datamanager]
logger.debug('API response', { requestId });
},
};
Note: You don't need to create or configure the logger; it's provided automatically with proper scoping.
interface Logger.Instance {
error(message: string | Error, context?: unknown | Error): void;
warn(message: string | Error, context?: unknown | Error): void;
info(message: string | Error, context?: unknown | Error): void;
debug(message: string | Error, context?: unknown | Error): void;
throw(message: string | Error, context?: unknown): never;
json(data: unknown): void;
scope(name: string): Logger.Instance;
}
Default: ERROR only (must configure to see WARN/INFO/DEBUG)
All methods accept optional structured context:
logger.debug('Sending to API', {
endpoint: '/events',
method: 'POST',
eventCount: 5,
});
// Output: DEBUG [datamanager] Sending to API { endpoint: '/events', method: 'POST', eventCount: 5 }
Why: Collector can log these automatically since it calls init/push and has scoped logger.
warn: walkerOS acted, the intent is still met)StepError, not a log lineimport { StepError } from '@walkeros/core';
// ✅ GOOD - A missing setting is a failure: throw, never return or log
async init({ config }) {
const { apiKey, projectId } = config.settings || {};
if (!apiKey)
throw new StepError('Config settings apiKey missing', { code: 'config' });
if (!projectId)
throw new StepError('Config settings projectId missing', {
code: 'config',
});
}
Why a thrown StepError:
code and retryable tell a server source whether to ask the producer to
resend (config, missing-input and a 4xx are not retryable)logger.throw only throws. It writes no log line, so it is not a way to
report a failureNever return early from init or push instead of throwing: a step that
returns normally counts as started, and a push that returns normally counts as
delivered. return false from init fails the push with the code not-ready,
which does not name the missing setting.
import { StepError } from '@walkeros/core';
// ✅ GOOD - Trace the call at debug, throw on a failure
async push(event, { config, logger }) {
const endpoint = 'https://api.vendor.com/events';
logger.debug('Calling API', { endpoint, method: 'POST', eventId: event.id });
const response = await fetch(endpoint, {
method: 'POST',
body: JSON.stringify(event),
});
logger.debug('API response', { status: response.status, ok: response.ok });
if (!response.ok)
// The status sets retryable (429 and 5xx retry, other 4xx do not). The
// response body goes on `body`, never into the message, and never into a
// log line.
throw new StepError(`HTTP ${response.status}`, {
code: 'transport',
status: response.status,
body: await response.text(),
});
}
Prefer sendWeb / sendServer: they already throw a StepError with the
status and body.
import { StepError } from '@walkeros/core';
// ✅ GOOD - Trace the client creation, throw on failure
async init({ config, logger }) {
try {
const authClient = await createAuthClient(config.settings);
logger.debug('Auth client created');
return {
env: { authClient },
};
} catch (error) {
throw new StepError('Authentication failed', {
code: 'config',
cause: error,
});
}
}
The SDK's own message stays on cause, so a vendor error that carries personal
data never reaches a log line.
// ✅ GOOD - Log server listening (high-level info); routeLines lists one line
// per method and path the source serves
if (settings.port !== undefined) {
server = app.listen(settings.port, () => {
env.logger.info(
`Express source listening on port ${settings.port}\n` + routeLines,
);
});
}
async init({ logger }) {
logger.debug('Data Manager init started'); // Redundant
logger.info('Data Manager initializing...'); // Redundant
logger.debug('Settings validated'); // Redundant
const authClient = await createAuthClient();
logger.debug('Auth client created'); // OK
logger.info('Data Manager ready'); // Redundant
}
Problem: Collector knows when init is called. Only log meaningful operations (auth client creation).
async push(event, { logger }) {
logger.debug('Processing event', {
// Redundant
name: event.name,
id: event.id,
});
// Do work...
logger.info('Event processed'); // Redundant
}
Problem: Collector knows when push is called and can log automatically.
// ❌ NEVER use console.log in sources/destinations
console.log('Processing event:', event.name);
// ✅ Use logger instead
logger.debug('API call', { endpoint });
When updating a source/destination to use the logger:
console.log, console.warn, console.error statementsStepError with a code for every failure (apiKey missing,
failed request, unsendable event); never log a failure and returnlogger.debug before external API calls (with endpoint, method)logger.debug after external API calls (with response status)logger.debug for auth operations (client creation, token refresh)Use createMockLogger from @walkeros/core to check debug traces. To prove
that a failure is reported, start a real collector (startFlow), mock only the
network or the vendor global, and read the push result; a mocked collector
cannot see loss:
import { startFlow } from '@walkeros/collector';
test('a missing apiKey fails the push', async () => {
const { elb } = await startFlow({
destinations: { vendor: { code: destination, config: { settings: {} } } },
});
const result = await elb({ name: 'page view' });
expect(result.ok).toBe(false);
expect(result.failed?.vendor.reason?.code).toBe('config');
});
Default log level is ERROR. To see INFO/DEBUG logs:
import { startFlow } from '@walkeros/collector';
const { elb } = await startFlow({
logger: {
level: 'DEBUG', // Show all logs
},
destinations: {
/* ... */
},
});
Levels:
'ERROR': Only errors (default)'WARN': Errors + warnings'INFO': Errors + warnings + info'DEBUG': EverythingThe levels follow the contract under Log Levels. A skipped event
writes a DEBUG line; a consent wait writes no line, and the push result lists
the destination under queued with the reason consent. Neither is a failure.
Format: on a server flow, "collector": { "logger": { "format": "json" } }
prints one JSON object per line (severity, message, time, scope,
context), which platforms such as Cloud Run read as structured logs. A web
flow rejects format. The flow's own handler and the runtime's handler both see
every line, so forwarding to a monitoring service needs no parsing.
The Observe reporter forwards the causes the logger writes, so a failure that
reaches a screen is the same failure that reached the log. The cause log keeps
one entry per step, code and status, with its count, last time and last message,
and collector.observe.usage posts every held entry in each report. See the
Observe page.
Text that leaves outside a log line passes the logger's mask:
Logger.Config.mask is optional, (text: string) => string. The handler
masks log lines on its own; mask is for text a log line never carries, such
as an issue message in a report. A node host passes one that hides its known
secret values (createCLILoggerConfig does); without one the text is returned
unchanged.Logger.Instance.mask is required. A logger built by hand (a test double, a
host's own logger) needs a mask, and an identity function is enough:
mask: (text) => text. createMockLogger from @walkeros/core has one.redactLine from
@walkeros/core (patterns, every wos_ token, short Bearer and Basic
credentials), then cuts the message at 256 characters. A step throws a message
with no secret in it; the mask is the second line of defence, not the first.Key Files:
A server source endpoint is exposed to the open internet. Level choice decides whether ambient scanner noise turns into pages.
| Situation | Level | Also |
|---|---|---|
| Unparseable body, oversized payload | debug | count on collector.status.sources.<id>.rejected |
| Unknown path | no line | answered 404 |
| Event the collector rejects as invalid | error with the reason, one line per source and minute, no stack | counted as rejected; answered 400 only when the source waits for delivery |
Settled ok: false arriving after the HTTP ack | debug | the collector's failure line reports the cause at error; the ack already went out |
| Handler fault, rejected push promise | error | answered 500 |
Rules that follow from the table:
error for anything a stranger can trigger, apart from the
collector's invalid-event line, which the source does not repeat. On Cloud Run
an error-level stack trace on stderr opens an Error Reporting issue, so
scanner traffic becomes an alert; the invalid-event line carries no stack.ok: false are different things. If a
helper collapses both into one return shape, log the thrown case inside that
helper at error, because the call site can no longer tell them apart.Reference pattern: packages/server/sources/express/src/index.ts, the
error-boundary middleware for body-parser failures and the 400/500 split in the
synchronous POST branch.
Best Practice Examples:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
22 skills in this plugin
/walkeros-create-cmp-sourceUse when creating a new walkerOS CMP (consent management platform) source. Structured fill-in-the-blanks workflow that turns any CMP's consent API into a walkerOS source package. Covers CookieFirst, Usercentrics, CookiePro/OneTrust patterns and generalizes to any CMP./walkeros-create-destinationUse when creating a new walkerOS destination to send events to a vendor or API (GA4/gtag, Meta/Facebook Pixel, Mixpanel, Amplitude, a custom HTTP API, Measurement Protocol), web or server-side. Example-driven workflow: research the vendor SDK and define step examples before implementing the destination interface, env pattern, and mappings./walkeros-create-sourcenpx claudepluginhub elbwalker/walkeros --plugin walkerosOther plugins' skills for the same job