Skip to content

Getting Started

Get up and running with Crowlog in minutes.

Installation

Install Crowlog using your preferred package manager:

bash
pnpm install @crowlog/logger
bash
npm install @crowlog/logger
bash
yarn add @crowlog/logger

Requirements

Crowlog works in any JavaScript environment:

  • Node.js: Version 22.0.0 or higher (lower versions may work but are not tested)
  • Browsers: All modern browsers
  • Edge Runtimes: Cloudflare Workers, Deno, Bun, etc.

Your First Logger

Create a logger with a namespace to identify the source of your logs:

typescript
import { createLogger } from '@crowlog/logger';

const logger = createLogger({ namespace: 'my-app' });

logger.info('Application started');
// Output: {"level":"info","message":"Application started","timestampMs":1738878633123,"namespace":"my-app","data":{}}

Log Levels

Crowlog provides four log levels, ordered by severity:

typescript
logger.debug('Detailed debugging information');
logger.info('General informational messages');
logger.warn('Warning messages');
logger.error('Error messages');

Each level has a specific purpose:

LevelPurposeWhen to Use
debugDetailed diagnostic informationDevelopment, troubleshooting
infoGeneral informational messagesNormal operations, lifecycle events
warnWarning messagesPotentially harmful situations
errorError messagesError events that might still allow the app to continue

Logging Interface

Crowlog supports two logging patterns:

Simple Message

Log just a message string:

typescript
logger.info('User logged in');

Structured Data with Message

Log data along with a message:

typescript
logger.info(
  { userId: '123', email: '[email protected]' },
  'User logged in'
);

Best Practice

Always include structured data when logging events. This makes logs searchable and easier to analyze.

What's Logged?

Every log entry contains:

json
{
  "level": "info", // The log level
  "message": "User logged in", // Your message
  "timestampMs": 1738878633123, // Unix timestamp in milliseconds
  "namespace": "my-app", // Logger namespace
  "data": { // Your structured data
    "userId": "123",
    "email": "[email protected]"
  }
}

Default Behavior

By default, Crowlog:

  • Outputs to stdout using JSON format
  • Includes all log levels (no filtering)
  • Default transport is stdout/console based
  • Adds timestamps to every log entry

Next Steps

Now that you have a basic logger running, explore:

  • Basic Usage - Learn core concepts and patterns
  • Transports - Control where logs are sent
  • Plugins - Add filtering, redaction, and more
  • Guides - Child loggers, factories, and testing

Need Help?

If you run into issues, open an issue on GitHub.

Released under the MIT License.