Coder Social home page Coder Social logo

logich's Introduction

Logich

logich is an extensible plugin based logging system inpired by express package and Node.js way of writing code. logich itself is just a empty shell to which you add middleware to process your logs.

For example, if you just use logich without any registered middleware it will do nothing:

var logich = require("logich");

var logger = logich();
logger.log("Hello world!"); // Does nothing...

To make it do something, you have to register middleware that will process your logs. You can use basic built-in middleware as follows:

var logger = logich()
    .use(logich.object)     // Converts message to object.
    .use(logich.time)       // Adds timestamp in JSON format to the object.
    .use(logich.json)       // Format log entry line as JSON.
    .use(logich.console);   // Prints messages to STDIN.

logger.log("Hello world!");

// Outputs the below in STDIN:
//{ message: 'Hello world!', time: '2014-11-15T15:54:46.059Z' }

Middleware

Write your own middleware:

logger.use(function(message, next) {
    // Do something with the log message...
    
    // Execute next middleware callback:
    next(message);
});

Or use already written middleware:

Built in middleware:

  • logich.object - Converts log message into an object {"message": "your log message"}.
  • logich.time - Adds current timestamp in JSON fromat, Date.toJSON().
  • logich.json - Converts log message to JSON string.
  • logich.console - Uses console.log() to print log message.

logich's People

Stargazers

 avatar

Watchers

 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.