Code Monkey home page Code Monkey logo

leucine's Introduction

Screenshot 2023-01-29 at 2 55 53 PM

⚛️ leucine

A tiny, hybrid logging framework for client and server side applications.

  • ✅ formatted, easy-to-read logs
  • ✅ automatic distinction between server-side and client-side logging
  • ✅ emoji first logging indicators
  • ✅ comes with 4 logging states (debug, info, warn, error)

Getting started

First, install leucine using npm/yarn/pnpn:

## npm
npm i leucine --save-dev

## yarn
yarn add leucine -D

## pnpm
pnpm add leucine -D

Then, import log, the main, named export from leucine:

import { log } from "leucine"

🎉 You're now ready to start logging:

const sum = (a, b) => a + b;

log(sum(1,2)); // 🐛 (debug): 5

By default, leucine will use debug mode. Refer to documention below to see how to configure the logging mode.

📘 Documentation

Changing the logging mode

By default, leucine defaults to debug mode for all console logging. To change modes, simply pass the mode as a string as the second parameter to the log function like so:

// Info.
log("This is an info log.", "info") // ℹ️ (info): ...

// Warn.
log("This is a warn log.", "warn") // ⚠️ (warn): ...

// Error.
log("This is an error log.", "error") // ⛔️ (error): ...

Valid modes are: debug, info, warn, and error

Note that leucine only formats logs and does not throw any exceptions on console warnings/errors.

Passing variable args to log

To pass a variable amount of arguments to log to the console, use an array like so:

const someVar = "I'm a variable!"

log(["This is a string", someVar, 10]) // 🐛 (debug): ["This is a string", "I'm a variable", 10]

⚙️ API Refrence

log(arg, level = "debug")

  • arg: T
  • level: "debug" | "info" | "warn" | "error"
  • Returns void

leucine's People

Contributors

shaunchander 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.