Skip to content

Commit ab00b34

Browse files
fix(indiekit): enable debugging when debug flag set
1 parent f7fc748 commit ab00b34

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/indiekit/bin/cli.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
2-
import process from "node:process";
32
import { Command } from "commander";
3+
import makeDebug from "debug";
4+
45
import { Indiekit } from "@indiekit/indiekit";
56
import { defaultConfig } from "../config/defaults.js";
67

@@ -19,7 +20,8 @@ program
1920
const { debug, port } = options;
2021

2122
if (debug) {
22-
process.env.DEBUG = debug ? `${debug}:*` : "*";
23+
// Debug everything if no scope, else only debug within provided scope
24+
makeDebug.enable(debug === true ? `*` : debug);
2325
}
2426

2527
const indiekit = new Indiekit({

packages/indiekit/lib/middleware/logging.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import Debug from "debug";
1+
import makeDebug from "debug";
22

3-
const debug = new Debug("indiekit:request");
3+
const debug = makeDebug("indiekit:request");
44

55
export const logging = (request, response, next) => {
6+
// Send debug logging output to console.info
7+
debug.log = console.info.bind(console);
8+
69
debug("url", request.originalUrl);
710
debug("headers", request.headers);
811
debug("body", request.body);

0 commit comments

Comments
 (0)