@netscript/logger@0.0.10Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Structured logging for NetScript services, packages, workers, and jobs, built on LogTape: configure once at startup, create category-scoped loggers, and bind request-scoped context across the runtime.
@netscript/logger
Structured logging for NetScript services, packages, workers, and jobs, built on LogTape: configure once at startup, create category-scoped loggers, and bind request-scoped context across the runtime.
Every NetScript process logs through the same hierarchy: configureLogging() sets up LogTape once —
human-readable text in local development, structured JSON in production — and the creator functions
hand out loggers under a consistent netscript·… category tree, so a service, a worker, and a job
all emit records an operator can filter the same way. withContext() binds request-scoped fields
onto every record emitted inside a callback, and the middleware and oRPC subpaths wire that context
into HTTP and RPC handling automatically.
Why teams use it
- Category-scoped creators —
createServiceLogger,createPackageLogger,createWorkerLogger,createJobLogger, andcreateChildLoggerproduce loggers with a consistent NetScript category hierarchy. - One-shot configuration —
configureLoggingandensureLoggingset up LogTape with environment-aware sinks;isLoggingConfiguredandresetLoggingcover lifecycle and test isolation. - Hono request logging —
@netscript/logger/middlewareexposesloggerMiddleware, injecting a request-scoped logger and request ID and logging start, completion, and failure with sensitive-field redaction. - oRPC integration —
@netscript/logger/orpcexposesLoggingPluginandcreateLoggingPluginto log oRPC handler and client interceptions, correlated per request byrequestIdeven under concurrent traffic. Debug-mode input logs redact sensitive fields, extensible withredactFields. - LogTape contract re-exported —
getLogger,getConsoleSink,withContext, and theLogger,LogRecord,LogLevel, andSinktypes pass through unchanged, so anything LogTape can do stays available.
Install
deno add jsr:@netscript/logger@<version>
Pin <version> to match your installed CLI; bare jsr:@netscript/* specifiers do not resolve on
the pre-release line.
Quick example
import { configureLogging, createServiceLogger, withContext } from '@netscript/logger'; await configureLogging({ level: 'info' }); const logger = createServiceLogger('users'); logger.info('Service starting', { port: 3000 }); // Bind request-scoped fields onto every record emitted in the callback. withContext({ requestId: 'req-42' }, () => { logger.info('Handling request'); });
In development this prints readable lines under the service category
(netscript·services·users Service starting); in production the same calls emit structured JSON.
Use ensureLogging() instead of configureLogging() on shared startup paths that may run more than
once.
oRPC request correlation
LoggingPlugin reuses an incoming requestId from oRPC context (such as the ID propagated by
loggerMiddleware / X-Request-ID in @netscript/service) and falls back to a fresh per-request
ID when absent, keeping HTTP access logs, RPC logs, and procedure handlers correlated:
import { LoggingPlugin } from '@netscript/logger/orpc'; const plugin = new LoggingPlugin({ serviceName: 'orders', redactFields: ['brief'], }); void plugin;
Public surface
| Entry | What it gives you |
|---|---|
. |
configureLogging / ensureLogging, category-scoped creators, LogTape re-exports |
./middleware |
loggerMiddleware and request-ID/logger injection helpers for Hono |
./orpc |
LoggingPlugin / createLoggingPlugin for oRPC handler and client logging |
The always-current symbol list is
deno doc jsr:@netscript/logger@<version> (pin <version>
on the pre-release line, as above).
Docs
- Reference — configuration, creators, middleware, and plugins: rickylabs.github.io/netscript/reference/logger/
- Observability — logging, tracing, and the dashboard together: rickylabs.github.io/netscript/observability/
- API docs on JSR: jsr.io/@netscript/logger/doc
Compatibility
Runs wherever LogTape does — Deno, Node.js, and Bun. Environment-aware sink selection reads
environment variables, so grant --allow-env under Deno. The middleware subpath targets Hono 4 and
the oRPC subpath targets @orpc/server 1.x; both stay out of your module graph unless imported.
License
Apache-2.0 — see LICENSE. Published to JSR with cryptographically verified provenance.
Examples
Example 1
Example 1
import { configureLogging, createServiceLogger } from '@netscript/logger'; await configureLogging({ level: 'info' }); const logger = createServiceLogger('users'); logger.info('Service starting', { port: 3000 });
Example 2
Example 2
import { loggerMiddleware } from '@netscript/logger/middleware'; import { LoggingPlugin } from '@netscript/logger/orpc';
Add Package
deno add jsr:@netscript/logger
Import symbol
import * as logger from "@netscript/logger";
Import directly with a jsr specifier
import * as logger from "jsr:@netscript/logger@^0.0.10";