Giter Site home page Giter Site logo

leg's Introduction

leg

logs of json

Overview

leg! leg because lel! leg is a stupidly simple JSON-based logging thingy. It works the way I want it to, and you might also garner some utility from it. If not, that's fine.

Super Quickstart

var log = require("leg")();

log.info("something happened!", {some: "other", things: "here"});
["2013-05-13T04:11:00.664Z","INFO","something happened!",{"some":"other","things":"here"}]

Installation

Available via npm:

$ npm install leg

Or via git:

$ git clone git://github.com/deoxxa/leg.git node_modules/leg

API

leg

Creates a new logging function thing. Optionally takes a writable stream to output to as an argument. By default, will use process.stderr. The return value is a function that you can use to log things!

leg([stream], [options]);
// instantiate with default process.stderr output
var log = leg();

// instantiate with different output
var log = log(process.stdout);

// instantiate with options
var log = log(null, {object: true});

log

This is the return value of leg(). It takes three arguments, with the last one being optional. It also has a few convenience things tacked onto it, read on below for more info on them.

log(level, text, [info]);
// log without any context information
log("EMERGENCY", "there are very few donuts left");

// log with some useful context data
log("EMERGENCY", "there are very few donuts left", {donutCount: 3});
["2013-05-13T04:13:51.640Z","EMERGENCY","there are very few donuts left",null]
["2013-05-13T04:13:51.640Z","EMERGENCY","there are very few donuts left",{"donutCount":3}]

Arguments

  • level - the coarse level of the log message. e.g. "ERROR"
  • text - the main text body of the message. e.g. "received request"
  • info - any kind of JSON.stringify-able value (default null)

debug info warn error

These are all properties of the log function. They just provide a suggested set of log levels. You can even create your own!

log.debug(text, info)
log.info(text, info)
log.warn(text, info)
log.error(text, info)
log.debug("some debugging info", {someMetric: 12345});
["2013-05-13T04:20:50.477Z","DEBUG","some debugging info",{"someMetric":12345}]

Arguments

  • text - same as text in log
  • info - same as info in log

Creating your own

log.silly = log.bind(log, "SILLY");
log.silly("yippee", {woo: "hoo"});
["2013-05-13T04:22:36.299Z","SILLY","yippee",{"woo":"hoo"}]

License

3-clause BSD. A copy is included with the source.

Contact

leg's People

Contributors

deoxxa avatar hamidtopup 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.