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 🙏

© 2024 – Pkg Stats / Ryan Hefner

loghorn

v1.0.0

Published

Colorful simple logger for Node.js

Downloads

240

Readme

loghorn

NPM Package: loghorn

Introduction

Loghorn is a powerful, colorful logging utility for Node.js applications that provides environment-specific configuration support for both Backend and Frontend environments. It enables enhanced debugging with customizable, readable, and fancy logs.

🚀 Key Features

  • ✅ Environment-specific configuration
  • ✅ TypeScript support with strict typing
  • ✅ Comprehensive JSON logging support
  • ✅ Multiple log levels (Debug, Info, Warn, Error, Trace, Log)
  • ✅ Configurable log level restrictions per environment
  • ✅ Customizable colors and emojis for each log level
  • ✅ Middleware logging support
  • ✅ Browser console compatibility
  • ✅ Environment variable configuration

🛠️ Installation

# Using npm
npm install loghorn

# Using yarn
yarn add loghorn

# Using pnpm
pnpm add loghorn

📋 Quick Start

Once installed you import logger or any log method like info, error, etc.. for use:

import logger, { info } from 'loghorn';

const info = {
  auther: {
    email: '[email protected]',
    website: 'http://nasraldin.com',
    twitter: 'https://twitter.com/_nasraldin',
  },
  git: 'https://github.com/nasraldin/loghorn',
  npm: 'https://www.npmjs.com/package/loghorn',
};

// Basic logging
logger.log(info);
// or you can print like
logger.log({ info });
logger.debug('Debug information', { details: 'some data' });
logger.info('log info', { info });
logger.warn('log warn', info);
logger.error('log error', info);
logger.fatal('log fatal', info);
logger.trace('log trace', info);
logger.table('log trace', info);

// With middleware options
info('Middleware executed', { data }, { isMiddleware: true });

⚙️ Configuration

Environment Variables

Configure loghorn using environment variables:

# Core settings
ENABLE_LOGS=true
LOG_APP_NAME=loghorn
LOG_LEVEL=trace

# Message template
LOG_MESSAGE_TEMPLATE='{@LogLevel} {@Application} {@Env} at {Timestamp}'

# Output settings
WRITE_LOGS_TO=console,browser
MIDDLEWARE_LOGS=true

# Seq integration (optional)
WRITE_LOGS_TO_SEQ=false
SEQ_URL=http://localhost:5341/api/events/raw
SEQ_API_KEY=api_key

# For Next.js applications you can append NEXT_PUBLIC_ to the config name
NEXT_PUBLIC_LOG_APP_NAME=loghorn

🔍 Log Levels

Available log levels in order of severity:

  • TRACE - Detailed debugging information
  • DEBUG - Debugging messages
  • INFO - General information
  • WARN - Warning messages
  • ERROR - Error conditions
  • FATAL - Critical errors that require immediate attention

🤝 Contributing

Contributions are welcome! Please read our contributing guidelines and code of conduct before submitting pull requests.

Development Setup

  1. Fork the repository
  2. Clone your fork
  3. Install dependencies
  4. Create a feature branch
  5. Make your changes
  6. Submit a pull request

📝 License

See LICENSE for more information.

Authors