GithubHelp home page GithubHelp logo

loglin / loglin Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 494 KB

Super fast & lightweight Node.js logger

Home Page: https://loglin.dev

JavaScript 4.47% TypeScript 95.53%
nodejs logger fast pluggable typescript

loglin's Introduction

loglin

Super fast, lightweight and extensible logger for Node.js

npm version npm downloads

Why loglin?

⚡️  Lightning Fast Logging
🛠️  Rich Features
🔌  Pluggable Reporters
🍃  Lightweight
👶  Easy To Use
🔑  Fully Typed

Installation

1. Core

# pnpm
pnpm install loglin

# npm
npm i loglin

# yarn
yarn add loglin

2. Minimum one reporter (e.g. reporter-console)

See all Available Reporters

# pnpm
pnpm install @loglin/reporter-console

# npm
npm i @loglin/reporter-console

# yarn
yarn add @loglin/reporter-console

Getting Started

// With imports
import { createLogger } from 'loglin'
import { consoleReporter } from '@loglin/reporter-console'

// With require
const { createLogger } = require('loglin')
const { consoleReporter } = require('@loglin/reporter-console')

// Create logger instance
const logger = createLogger({
    reporters: [
        consoleReporter()
    ]
})

// Use log methods
logger.success('Successfully built')
logger.fatal(new Error('Something bad happend'))
logger.info('Some info', { foo: 'bar' })
// ...

Log Methods

  • logger.fatal()
  • logger.error()
  • logger.warn()
  • logger.log()
  • logger.info()
  • logger.success()
  • logger.debug()

Each log method can receive the actual log data as the first argument and optional meta data as the second argument. The meta data is for providing some additional information which you can check/print/process in your reporter's log function.

Example:

logger.info('Received info', { name: 'Foo Bar' })

Log Levels

  • LogLevel.Fatal
  • LogLevel.Error
  • LogLevel.Warn
  • LogLevel.Log
  • LogLevel.Info
  • LogLevel.Success
  • LogLevel.Debug

Available Reporters

Available Filters

isMinimumLevel(level)

level

  • Type: LogLevel

Minimum level where the logger should execute the log function. Can be any of the Log Levels.

API

createLogger(options)

reporters

  • Type: Reporter[]
  • Default: []

Specify the reporters the logger should use. Minimum one is required.

filters

  • Type: Filter[]
  • Default: []

Global filters for filtering out logs of all reporters. Perfect for filtering logs based on the log level.
See Available Filters.

License

MIT

loglin's People

Contributors

dependabot[bot] avatar m4rvr avatar renovate-bot avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.