Git Product home page Git Product logo

hzslogger's Introduction

hzslogger

This is version 2 of the old hslogger.

var logger = require("hzslogger")({
  enabled: true,  //defaults to true
  preSave: function(log){ ... }, //optional, function to review/mutate the log. Return `false` to cancel the message.
  defaults: { env: "PRODUCTION", ... }, //optional, object with default fields
  connectionString: "" //required or set `process.env.HZSLOGGER_CONNECTION_STRING`,
  onError: function(msg){ } //optional, error messages go to console.error unless this is set
});

logger({event:"signed-in", userid:"2345"});

NOTE: The logger will mutate the log object with defaults (for performance reasons).

Recommended Fields

The logged object has no required fields, but there are some standards.

  • time - Milliseconds since epoch. E.g. `new Date().getTime()``. If not set, it will be added.
  • env - real|demo|staging|dev
  • proc - web|worker|api|grind|etc
  • source - router|app
  • pid - web.1|worker.1|etc
  • event - e.g. daily-billing, timelog, request
  • msg - description of event

Example Configurations

// Encode query string with http://pressbin.com/tools/urlencode_urldecode
heroku drains -a hzs-web
heroku drains:remove -a hzs-api
heroku drains:add https://hzslogger.hazardscout.com/api/syslog?{"defaults":{"env":"demo","proc":"web"}} -a hzs-web-demo

// Examples
heroku drains:add https://hzslogger.hazardscout.com/api/syslog?%7B%22defaults%22%3A%7B%22env%22%3A%22real%22%2C%22proc%22%3A%22web%22%7D%7D -a hzs-web
heroku drains:add https://hzslogger.hazardscout.com/api/syslog?%7B%22defaults%22%3A%7B%22env%22%3A%22real%22%2C%22proc%22%3A%22api%22%7D%7D -a hzs-api
heroku drains:add https://hzslogger.hazardscout.com/api/syslog?%7B%22defaults%22%3A%7B%22env%22%3A%22real%22%2C%22proc%22%3A%22grind%22%7D%7D -a hzs-grind

Background

hslogger required a mongodb driver like mongojs which was difficult to install on some servers because of dependencies like libkrb5. So this logger actually sends logs to our logging server via https which is extremely lightweight.

hzslogger's People

Contributors

bendytree avatar

Watchers

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