Git Product home page Git Product logo

abc-log's Introduction

abc-log

Configurable JSON.stringify() logging to any output stream.

  • Configurable stringify (see abc-stringify)
  • Configurable output stream
  • Configurable levels
  • Configurable time, level, and log property names
  • Configurable watch file to change log level

Quick Start

const AbcLog = require('abc-log')
const log = new AbcLog({ level: 'info' })
const o = {
  error: new Error('something bad happened'),
  name: 'freddy',
  address: {
    street: '1234 lane st',
    city: 'hereshey',
    st: 'PA',
    zip: '19293'
  },
  nest: {
    really: {
      deep: {
        stuff: ['one', 2, 'three']
      }
    }
  }
}
o.circular = o
// Signature is compatible with JSON.stringify(value, replacer, space)
log.info(o, 2) // same as log.info(o, null, 2)

Results

{
  "time": "2019-08-05T18:13:25.785Z",
  "level": "info",
  "log": {
    "error": {
      "name": "Error",
      "message": "something bad happened",
      "stack": "Error: something bad happened\n    at Object.<anonymous> (/abc-log/index.js:70:12)\n    at Module._compile (internal/modules/cjs/loader.js:776:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)\n    at Module.load (internal/modules/cjs/loader.js:653:32)\n    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\n    at Function.Module._load (internal/modules/cjs/loader.js:585:3)\n    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)\n    at startup (internal/bootstrap/node.js:283:19)\n    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)"
    },
    "name": "freddy",
    "address": {
      "street": "1234 lane st",
      "city": "hereshey",
      "st": "PA",
      "zip": "19293"
    },
    "nest": {
      "really": {
        "deep": {
          "stuff": [
            "one",
            2,
            "three"
          ]
        }
      }
    },
    "circular": "--circular--"
  }
}

abc-log's People

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.