Giter Site home page Giter Site logo

meteor-logger's Introduction

Lookback Logger

Circle CI

A Meteor logger that logs to Loggly or local console.log on the server (no client side support as of now).

Install

Lookback Logger is available on Atmosphere as lookback:logger:

meteor add lookback:logger

Usage

A global Logger object is automatically exported from within the package and available in your app (server side only). It has the log level methods debug, warn, error and info.

Logger.info('Some logging');
Logger.warn('Watch out!');
Logger.error('Someone screwed up ...');
Logger.debug('Herp-a-derp!');

Locally, the info, warn, debug, and error methods correspond to their corresponding methods on the console object (with the exception of debug: it uses console.log).

Each Logger method takes a message as a string, and optionally an array of tags:

Logger.info('Some logging', ['my-tag']);

This can be shown in the Loggly interface.

Additionally, a global logger factory function is exported. It is used to create a logger:

someLogger = logger(params);

logger takes an object of parameters:

myLogger = logger({
  // Local logging. Defaults to true.
  local: true,

  // Loggly options. Defaults to {}. If set, local logging will be disabled.
  loggly: {
    // Options to send to the Loggly npm module.
    logglyModuleOptions: {
      token: '<your loggly token>',
      subdomain: 'foobar',
      json: true
    },
    // Params to send to Loggly with every request.
    baseParams: {
      environment: 'development',   // Defaults to process.env.NODE_ENV
      serverName: 'My Computer'
    }
  }
});

Please refer to the documentation for the loggly npm module for documentation on the logglyModuleOptions.

Tests

meteor test-packages lookback:logger

Locally:

meteor test-packages ./

Version history

  • 1.1.1 - Important fix for all loggers not being called.
  • 1.1.0 - Locally, output tags in front of message for easy scanning.
  • 1.0.0 - Initial publish.

Contributions

Contributions are welcome. Please open issues and/or file Pull Requests.

Made by Lookback.

meteor-logger's People

Contributors

johanbrook avatar datacarl avatar

Stargazers

Ivan Chalyk avatar Max Pleaner avatar Sharad K avatar gregory nicholas avatar Andrii Kuz avatar Fabio Dias Rollo avatar Gabriel Almeida avatar Tomas Brambora avatar  avatar Joe avatar Nick Wientge avatar Chris Parker avatar Thibault Lenclos avatar Johnie Hjelm avatar

Watchers

Andreas Smas avatar Jonatan Littke avatar Francis Byrne avatar  avatar Pete Nelson avatar James Cloos avatar Ian Bytchek avatar  avatar Hugo Tunius avatar Frida Issa avatar craig james avatar Scott Edgar avatar  avatar  avatar  avatar

meteor-logger's Issues

global object Logger is not defined on server

Hi, I installed your package on Meteor 1.0.3 and tried to use it on the server.

The first file to use it is server/lib/settings.coffee but my app is crashing as Logger is not defined.

Is this reproducable for anyone else or maybe I've just done something wrong.

ReferenceError: logger is not defined

Hi there,

I installed lookback:logger this morning and put the following code in /client/etoeventSubmit.js:

Template.etoeventSubmit.events({
  'submit form': function (e) {
    e.preventDefault();

    var etoeventStart = roundToNearestQuarterHour(
      moment($(e.target).find('[name=etoeventStart]').val(), 'MM/DD/YYYY hh:mm a'));
    var etoeventStop = roundToNearestQuarterHour(
      moment($(e.target).find('[name=etoeventStop]').val(), 'MM/DD/YYYY hh:mm a'));

    myLogger.info('etoeventStart: ' + etoeventStart);
    myLogger.info('etoeventStop: ' + etoeventStop);

    // ...

});

I also made /lib/environment.js and it has the following:

myLogger = logger({
  // Local logging. Defaults to true.
  local:  true,

  // Loggly options. Defaults to {}. If set, local logging will be disabled.
  loggly: {
    // Options to send to the Loggly npm module.
    logglyModuleOptions: {
      token:     '<token>',
      subdomain: '<subdomain>',
      json:      true
      },
      // Params to send to Loggly with every request.
      baseParams: {
        environment: 'development',   // Defaults to process.env.NODE_ENV
        serverName: '<workstation name>'
    }
  }
});

What am I doing wrong? I'm fairly new to Javascript, Loggly, and Meteor so please excuse any glaring oversight I've made.

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.