Giter VIP home page Giter VIP logo

logger-nodejs's Introduction

resurfaceio-logger-nodejs

Logging usage of Node.js-based services, with user privacy by design.

Visit resurface.io for general information on usage logging.

npm version

Contents

Requires Node.js 10.x or later. No other dependencies to conflict with your app.

npm install resurfaceio-logger --save

After installing the module, add a HttpLoggerForExpress instance to your app, after any body parsers in use.

const express = require('express');
const app = express();

// add body parsers

const resurfaceio = require('resurfaceio-logger');
resurfaceio.HttpLoggerForExpress.add(app, {
    url: 'http://localhost:4001/message', 
    rules: 'include debug'
});

// define routes

After installing the module, add a HttpLoggerForExpress instance before calling applyMiddleware.

const app = express();

const resurfaceio = require('resurfaceio-logger');
resurfaceio.HttpLoggerForExpress.add(app, {
    url: 'http://localhost:4001/message', 
    rules: 'include debug'
});

const server = new ApolloServer({ ... });

server.applyMiddleware({ app });

After installing the module, create a logger and call it from the routes of interest.

const express = require('express');
const app = express();

const resurfaceio = require('resurfaceio-logger');
const logger = new resurfaceio.HttpLogger({
    url: 'http://localhost:4001/message',
    rules: 'include debug'
});

app.get('/', function (request, response) {
    response.render('pages/index', function (e, html) {
        response.status(200).send(html);
        resurfaceio.HttpMessage.send(logger, request, response, html);
    });
});

Loggers can be directly integrated into your application using our API. This requires the most effort compared with the options described above, but also offers the greatest flexibility and control.

API documentation

Loggers always have an active set of rules that control what data is logged and how sensitive data is masked. All of the examples above apply a predefined set of rules (include debug), but logging rules are easily customized to meet the needs of any application.

Logging rules documentation


© 2016-2021 Resurface Labs Inc.

logger-nodejs's People

Contributors

robdickinson avatar

Watchers

James Cloos 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.