npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

drizzle-query-logger

v1.1.1

Published

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.

Readme

🎨 drizzle-query-logger

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.

✨ Features

  • 🎨 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

📦 Installation

npm install drizzle-query-logger
yarn add drizzle-query-logger
pnpm add drizzle-query-logger
bun add drizzle-query-logger

📸 Before vs After

Before (Default Drizzle Logger)

Before - Default Drizzle Logger

After (Enhanced Query Logger)

After - Enhanced Query Logger

See the dramatic difference! The enhanced logger transforms plain SQL output into beautifully formatted, color-coded queries with syntax highlighting, icons, and structured parameter display.

🚀 Usage

Basic Usage

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);

With Custom Logger Function

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 });

🎯 Query Types & Icons

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 |

🛠️ Configuration

Constructor Options

interface LoggerOptions {
  log?: (message: string) => void;
}
  • log: Custom logging function (default: console.log)

Example with Custom Configuration

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);
    }
  }
});

🎨 Color Scheme

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

🔧 TypeScript Support

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;
}

📋 Requirements

  • Node.js: 16+
  • TypeScript: 5+ (peer dependency)
  • Drizzle ORM: Compatible with all recent versions

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT License - see the LICENSE file for details.

🙏 Acknowledgments

Built for the Drizzle ORM ecosystem.

⭐ Star History

Star History