Code Monkey home page Code Monkey logo

heroku-log's Introduction

Heroku-log

Console.log wrapper for heroku-like logs

Build Status

Install

yarn

yarn add heroku-log

npm

npm install heroku-log --save

Available levels

import {
  info,
  debug,
  error,
  warn,
  trace,
  fatal
} from 'heroku-log'

Example

import herokuLog, { error } from 'heroku-log'

// # On Heroku
herokuLog.info('Server is starting')
// 2017-05-24T08:58:42.857401+00:00 app[web.1] level=info message="Server is starting"

error(new Error('I am an error '))
// 2017-05-24T08:58:42.857401+00:00 app[web.1] level=error error="I am an error"

Tricks

Sometimes you don't want those logs e.g. when testing things, in this case you can pass a env variable in the command line and the module is muted

$ HEROKU_LOG=disable mocha test.js

Timestamps

If the environment is not production heroku-log will add a simple time-mark at the beginning of each log, in production it will be hidden since Heroku adds a time block by itself.

heroku-log's People

Contributors

michaelzoidl avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

heroku-log's Issues

Cannot read property 'level' of undefined

If the module wants to log something sometimes it throws an error that it doesnt find a level, here is the message:

/Users/michaelzoidl/Code/**/node_modules/heroku-log/build/index.js:68
    return a.level;
            ^

TypeError: Cannot read property 'level' of undefined
    at /Users/michaelzoidl/Code/**/node_modules/heroku-log/build/index.js:68:13

Here is line 68 of build/index.js

// ...
  var prop = args.find(function (a) {
    return a.level;
  }) || {};
// ...

Time should always be a two-digit number

Numbers between 0 and 9 should also be shown as two-digit number (01 instead of 1)

[17:47:58] DEBUG ···· <log message>
[17:48:0] DEBUG ···· <log message>

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.