Giter Club home page Giter Club logo

ignition's Introduction

Ignition

Build Status

Basic configuration and tooling shared across applications

Logging

var logging = require('ghost-ignition').logging({
    domain: 'example.com,
    env: 'production',
    mode: 'long',
    level: 'info',
    transports: ['file'],
    rotation: {enabled: true, period: '1d', count: 10},
    path: '/var/log'
});

mode         : long|short (default is `short`) - defines the output volume (helpful when logging requests)
level        : info|error|debug (default is `info`)
transports   : stdout|file|stderr (default is `['stdout']`)
path         : is used when file transport is enabled (default is `process.cwd()`)

logging.info({req: req, res: res});
logging.info('Info');
logging.error(new Error());
logging.warn('this', 'is', 'a', 'warning');
logging.debug('this is a debug mode');

env parameter

Each config option, can be passed as an environment variable: E.g. LEVEL=error or MODE=long.

There is also a special env var

LOIN=true

Which sets the LEVEL to info and the MODE to long, for maximum output.

Logging into file

We log JSON format into file. This is very easy to forward and easy to interprete. By default we create two log files:

  • errors log entries: contains only errors
  • all log entries: contains everything

You can easily make the log files readable by calling: cat your.log | bunyan

Loggly Stream

You can send your logs to loggly by configuring the logger like this:

var logging = require('ghost-ignition').logging({
    domain: 'example.com,
    env: 'production',
    mode: 'long',
    level: 'info',
    transports: ['file', 'loggly'],
    rotation: {enabled: true, period: '1d', count: 10},
    path: '/var/log',
    loggly: {
      token: 'your-token',
      subdomain: 'your-subdomain',
      match: 'regex as string to match specific properties only certain log entries'
    }
});

Example for match:
match: 'level:critical'
match: 'statusCode:500|statusCode:403'

NOTE: The loggly stream will only send error logs. Furthermore, you can only match a string in the error object.

Utils

var errors = require('ghost-ignition');

// you can pass any error and ignition will tell you if this is a custom ignition error
errors.utils.isIgnitionError(err);

// serialize an error to a specific format
errors.utils.serialize(err, {format: 'jsonapi|oauth'});

// deserialize specific format to error instance
errors.utils.deserialize(err);

Copyright & License

Copyright (c) 2016-2018 Ghost Foundation - Released under the MIT license.

ignition's People

Contributors

kirrg001 avatar erisds avatar acburdine avatar aileen avatar johnonolan avatar marcbachmann avatar cobbspur avatar sahand12 avatar

Watchers

Jeff Jewiss 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.