mirror of
https://github.com/diced/zipline.git
synced 2025-12-05 20:40:12 -08:00
fix: better DEBUG var handling
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
"build:next": "ZIPLINE_BUILD=true next build",
|
||||
"build:server": "tsup",
|
||||
"dev": "cross-env TURBOPACK=1 NODE_ENV=development DEBUG=zipline tsx --require dotenv/config --enable-source-maps ./src/server",
|
||||
"dev:nd": "cross-env TURBOPACK=1 NODE_ENV=development tsx --require dotenv/config --enable-source-maps ./src/server",
|
||||
"dev:inspector": "cross-env TURBOPACK=1 NODE_ENV=development DEBUG=zipline tsx --require dotenv/config --inspect=0.0.0.0:9229 --enable-source-maps ./src/server",
|
||||
"start": "cross-env NODE_ENV=production node --trace-warnings --require dotenv/config --enable-source-maps ./build/server",
|
||||
"start:inspector": "cross-env NODE_ENV=production node --require dotenv/config --inspect=0.0.0.0:9229 --enable-source-maps ./build/server",
|
||||
|
||||
@@ -15,6 +15,18 @@ export default class Logger {
|
||||
return new Logger(`${this.name}::${name}`);
|
||||
}
|
||||
|
||||
private isZiplineDebug(): boolean {
|
||||
const debugVar = process.env.DEBUG;
|
||||
if (!debugVar) return false;
|
||||
|
||||
if (debugVar === 'zipline') return true;
|
||||
|
||||
const parts = debugVar.split(',').map((v) => v.trim());
|
||||
if (parts.includes('zipline') || parts.includes('*')) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private format(message: string, level: LoggerLevel) {
|
||||
const timestamp = dayjs().format('YYYY-MM-DDTHH:mm:ss');
|
||||
|
||||
@@ -81,7 +93,7 @@ export default class Logger {
|
||||
}
|
||||
|
||||
public debug(args: string, extra?: Record<string, unknown>) {
|
||||
if (process.env.DEBUG !== 'zipline') return this;
|
||||
if (!this.isZiplineDebug()) return this;
|
||||
|
||||
this.write(args, 'debug', extra);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user