Skip to content

Commit 07d9ec8

Browse files
committed
chore: switch to debug module
1 parent d765fd5 commit 07d9ec8

File tree

4 files changed

+36
-15
lines changed

4 files changed

+36
-15
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ When defining an ability you need to provide the following properties:
154154

155155
### Debug
156156

157-
To run Yates in debug mode, set the `YATES_DEBUG` environment variable to `true`.
157+
To run Yates in debug mode, use the environment variable `DEBUG=yates`.
158158

159159
## Known limitations
160160

package-lock.json

+30-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
"uuid": "^9.0.0"
3939
},
4040
"dependencies": {
41+
"@types/debug": "^4.1.12",
42+
"debug": "^4.3.4",
4143
"lodash": "^4.17.21",
4244
"node-sql-parser": "^4.12.0",
4345
"type-fest": "^4.10.3"
@@ -46,4 +48,4 @@
4648
"@prisma/client": "^5.0.0",
4749
"prisma": "^5.0.0"
4850
}
49-
}
51+
}

src/index.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as crypto from "crypto";
22
import { Prisma, PrismaClient } from "@prisma/client";
3+
import logger from "debug";
34
import difference from "lodash/difference";
45
import flatMap from "lodash/flatMap";
56
import map from "lodash/map";
@@ -8,13 +9,7 @@ import { Expression, RuntimeDataModel, expressionToSQL } from "./expressions";
89

910
const VALID_OPERATIONS = ["SELECT", "UPDATE", "INSERT", "DELETE"] as const;
1011

11-
const DEBUG = process.env.YATES_DEBUG === "1";
12-
13-
const debug = (...args: unknown[]) => {
14-
if (DEBUG) {
15-
console.log(...args);
16-
}
17-
};
12+
const debug = logger("yates");
1813

1914
type Operation = (typeof VALID_OPERATIONS)[number];
2015
export type Models = Prisma.ModelName;

0 commit comments

Comments
 (0)