Skip to content

Commit

Permalink
fix(indiekit): enable debugging when debug flag set
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Jan 7, 2023
1 parent f7fc748 commit ab00b34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/indiekit/bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
import process from "node:process";
import { Command } from "commander";
import makeDebug from "debug";

import { Indiekit } from "@indiekit/indiekit";
import { defaultConfig } from "../config/defaults.js";

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

if (debug) {
process.env.DEBUG = debug ? `${debug}:*` : "*";
// Debug everything if no scope, else only debug within provided scope
makeDebug.enable(debug === true ? `*` : debug);
}

const indiekit = new Indiekit({
Expand Down
7 changes: 5 additions & 2 deletions packages/indiekit/lib/middleware/logging.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import Debug from "debug";
import makeDebug from "debug";

const debug = new Debug("indiekit:request");
const debug = makeDebug("indiekit:request");

export const logging = (request, response, next) => {
// Send debug logging output to console.info
debug.log = console.info.bind(console);

debug("url", request.originalUrl);
debug("headers", request.headers);
debug("body", request.body);
Expand Down

0 comments on commit ab00b34

Please sign in to comment.