-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathdebug.ts
More file actions
30 lines (27 loc) · 803 Bytes
/
debug.ts
File metadata and controls
30 lines (27 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Controls debugging behavior. If set to `true`, all debug options are enabled.
* If set to `false`, all debug options are disabled. Can also be an object with
* specific debug options to enable.
*
* {@default false}
*/
export type DebugControls = DebugOptions | boolean;
type DebugOptions = {
/** Log all queries */
queries?: boolean;
/** Log all INFO, NOTICE, and WARNING raised database messages */
notices?: boolean;
/** Log all results */
results?: boolean;
/** Include the SQL query that caused an error in the PostgresError object */
queryInError?: boolean;
};
export const isDebugOptionEnabled = (
option: keyof DebugOptions,
options?: DebugControls,
): boolean => {
if (typeof options === "boolean") {
return options;
}
return !!options?.[option];
};