mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-05 04:08:03 +00:00
gitconfig: name/email from chezmoi data, gh credential helper by PATH lookup (portable to darwin). claude: no credentials, history, projects, sessions, or plugin caches. ssh config as private_ (0600). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
/**
|
|
* Structured logging helpers. Output is JSON-per-line so Workers Observability
|
|
* + log-shipping pipelines can parse + index without regex hacks.
|
|
*/
|
|
|
|
import type { SiteverifyLogEntry, ErrorCode } from './types.js';
|
|
|
|
export interface LogContext {
|
|
durationMs: number;
|
|
upstreamStatus?: number;
|
|
errorCodes?: ErrorCode[];
|
|
cdataValue?: string;
|
|
remoteipPresent: boolean;
|
|
idempotencyKeyPresent: boolean;
|
|
}
|
|
|
|
export function logSiteverify(outcome: 'ok' | 'fail' | 'error', ctx: LogContext): void {
|
|
const entry: SiteverifyLogEntry = {
|
|
level: outcome === 'ok' ? 'info' : outcome === 'fail' ? 'warn' : 'error',
|
|
event: 'siteverify',
|
|
outcome,
|
|
duration_ms: ctx.durationMs,
|
|
upstream_status: ctx.upstreamStatus,
|
|
error_codes: ctx.errorCodes ?? [],
|
|
cdata_present: typeof ctx.cdataValue === 'string' && ctx.cdataValue.length > 0,
|
|
cdata_value: ctx.cdataValue,
|
|
remoteip_present: ctx.remoteipPresent,
|
|
idempotency_key_present: ctx.idempotencyKeyPresent,
|
|
ts: new Date().toISOString(),
|
|
};
|
|
// console.log goes to Workers logs and Observability.
|
|
// Using a JSON line for machine-readability.
|
|
console.log(JSON.stringify(entry));
|
|
}
|