Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
EnhancedQueryLogger
✓ import { EnhancedQueryLogger } from 'drizzle-query-logger'
✗ const EnhancedQueryLogger = require('drizzle-query-logger')
ESM-only; CommonJS require() will fail. Use named import.
LoggerOptions
✓ import type { LoggerOptions } from 'drizzle-query-logger'
✗ import { LoggerOptions } from 'drizzle-query-logger'
Type export only, use 'import type' to avoid runtime error.
EnhancedQueryLogger (default import)
✓ import EnhancedQueryLogger from 'drizzle-query-logger'
✗ const logger = require('drizzle-query-logger').default
Default export exists but named is preferred. Requires esModuleInterop for TypeScript.
Shows basic setup: create a Drizzle ORM instance with the enhanced logger, connecting to an SQLite in-memory database.
import { drizzle } from 'drizzle-orm/libsql';
import { createClient } from '@libsql/client';
import { EnhancedQueryLogger } from 'drizzle-query-logger';
const client = createClient({ url: ':memory:' });
export const db = drizzle(client, {
logger: new EnhancedQueryLogger(),
});
// Example query
const result = await db.select().from(usersTable);
Debug
Known issues
gotchaPeer dependency version mismatch: drizzle-orm must be >=0.44.3 and <1.0.0. Using older versions may break the Logger interface.fixUpdate drizzle-orm to >=0.44.3 <1.0.0 or use a compatible version.
affects: <0.44.3 || >=1.0.0
gotchaTypeScript peer dependency is version 5. Using TypeScript 4.x may cause type errors.fixInstall TypeScript 5 or later (npm install -D typescript@^5).
affects: <5.0.0
gotchaThe logger only works when passed to the Drizzle ORM client via the 'logger' option. Using it standalone or with other ORMs will not produce logging.fixEnsure you pass the logger instance to drizzle() as shown in documentation.
affects: *
gotchaCustom log function must accept a string parameter. Passing a function that expects other types may cause silent failures.fixDefine log function as (message: string) => void.
affects: *
Errors
Common errors & fixes
TypeError: drizzle_orm_logger_1.EnhancedQueryLogger is not a constructor
Using named import from CommonJS require() which doesn't contain the default export correctly.
fixChange 'const { EnhancedQueryLogger } = require('drizzle-query-logger')' to 'import { EnhancedQueryLogger } from 'drizzle-query-logger' Module "drizzle-query-logger" has no exported member 'LoggerOptions'
Attempting to import LoggerOptions as a runtime value instead of a type.
fixUse 'import type { LoggerOptions } from 'drizzle-query-logger'' instead of 'import { LoggerOptions } from 'drizzle-query-logger'' Cannot find module 'drizzle-query-logger' or its corresponding type declarations
Package not installed or TypeScript cannot resolve the module due to missing types or tsconfig settings.
fixRun 'npm install drizzle-query-logger' and ensure 'moduleResolution' is set to 'node16' or 'bundler' in tsconfig.json
Parameter 'message' implicitly has 'any' type
Using custom log function without type annotation for the message parameter.
fixAdd type: (message: string) => void for the log option.
Audit
Dependencies
drizzle-ormrequiredPeer dependency: implements Drizzle's Logger interface; requires drizzle-orm >=0.44.3 <1.0.0
typescriptoptionalPeer dependency: ships TypeScript definitions; requires TypeScript 5+ for compilation