Logging
Netpress now ships with a lightweight Laravel-style logger in core. It is available as the shared log helper, is bound into the service container as log and logger, and is used by the CLI, migrations, seeders, queue runtime, and the starter template.
Quick Example
import { log } from "@admicaa/netpress";
log.info("Booting HTTP kernel");
log.success("Users seeded");
log.warn("Queue connection is disabled", { connection: "sync" });
log.error("Invoice sync failed", { invoiceId: 12 });
log.debug("Resolved policy result", { ability: "posts.update", allowed: true });
The default console output includes:
- a timestamp
- a colored level label
- the formatted message
- optional context data
Available Methods
log.info(message, context?)log.success(message, context?)log.warn(message, context?)log.error(message, context?)log.debug(message, context?)log.raw(message, { method? })
context can be a string, object, array, or Error. Objects are formatted with util.inspect() so logs stay readable during local development.
Debug Logging
Debug logs are disabled by default. Enable them with one of these environment variables:
LOG_DEBUG=trueNETPRESS_LOG_DEBUG=trueAPP_DEBUG=true
LOG_DEBUG wins if multiple values are present.
Container Access
If you need the logger from framework-facing code, resolve it from the container:
import { container } from "@admicaa/netpress";
const logger = container.get("log");
logger.info("Container-bound logger is ready");
Applications created through the Application kernel bind both log and logger automatically.
Extending Later
The default logger writes to the console and lazy-loads chalk only when the logger is first resolved. If you want to replace the shared logger or add transports later:
import { createLogger, setLogger } from "@admicaa/netpress";
const logger = createLogger({
transports: [
{
write(line) {
process.stdout.write(`${line}\n`);
},
raw(message) {
process.stdout.write(`${message}\n`);
},
},
],
});
setLogger(logger);
That keeps the helper API stable even if you later add file logging, external shipping, or structured JSON output.