A beautiful, enhanced logger for Drizzle ORM that transforms your SQL queries into visually appealing, color-coded output with syntax highlighting, icons, and detailed formatting.
- π¨ Beautiful formatting with box-drawing characters and colors
- π SQL syntax highlighting with keyword colorization
- π Query type detection with specific colors and icons
- π·οΈ Table name extraction and highlighting
- π Parameter formatting with type-specific colors
- β° Timestamps for each query
- π’ Query numbering to track execution order
- βοΈ Configurable logging output
npm install drizzle-query-loggeryarn add drizzle-query-loggerpnpm add drizzle-query-loggerbun add drizzle-query-loggerSee the dramatic difference! The enhanced logger transforms plain SQL output into beautifully formatted, color-coded queries with syntax highlighting, icons, and structured parameter display.
import { createClient } from '@libsql/client/sqlite3';
import { drizzle } from 'drizzle-orm/libsql';
import { EnhancedQueryLogger } from 'drizzle-query-logger';
const client = createClient({ url: ':memory:' });
export const db = drizzle(client, {
  logger: new EnhancedQueryLogger(),
});
// Your queries will now be beautifully logged!
const users = await db.select().from(usersTable);import { EnhancedQueryLogger } from 'drizzle-query-logger';
const logger = new EnhancedQueryLogger({
  log: (message) => {
    // Send to your preferred logging service
    console.log(message);
    // or use your custom logger
    // winston.info(message);
    // pino.info(message);
  }
});
export const db = drizzle(client, { logger });The logger automatically detects and styles different query types:
| Query Type | Icon | Color | 
|---|---|---|
| SELECT | π | Green | 
| INSERT | π | Blue | 
| UPDATE | βοΈ | Yellow | 
| DELETE | ποΈ | Red | 
| CREATE | ποΈ | Magenta | 
| DROP | π₯ | Red | 
| ALTER | π§ | Cyan | 
| OTHER | β‘ | White | 
interface LoggerOptions {
  log?: (message: string) => void;
}- log: Custom logging function (default:- console.log)
const logger = new EnhancedQueryLogger({
  log: (message) => {
    // Custom logging logic
    if (process.env.NODE_ENV === 'development') {
      console.log(message);
    } else {
      // Send to logging service in production
      yourLoggingService.debug(message);
    }
  }
});The logger uses a carefully chosen color scheme for optimal readability:
- Keywords: Blue (SELECT, FROM, WHERE, etc.)
- Strings: Green
- Numbers: Cyan
- Booleans: Yellow
- Objects: Magenta
- Null values: Dimmed
- Table names: Yellow
- Framework elements: Gray with cyan accents
This package is written in TypeScript and provides full type definitions. It implements Drizzle's Logger interface:
import type { Logger } from 'drizzle-orm/logger';
export class EnhancedQueryLogger implements Logger {
  logQuery(query: string, params: unknown[]): void;
}- Node.js: 16+
- TypeScript: 5+ (peer dependency)
- Drizzle ORM: Compatible with all recent versions
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see the LICENSE file for details.
Built for the Drizzle ORM ecosystem.

