Giter Site home page Giter Site logo

marianoleonardo / dojot-module-logger-nodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from giovannicuriel/dojot-module-logger-nodejs

0.0 0.0 0.0 102 KB

A simple configurable logger for dojot modules

License: Apache License 2.0

TypeScript 63.94% JavaScript 36.06%

dojot-module-logger-nodejs's Introduction

dojot-module-logger

This component is a simple logger, based on winston, that offers an endpoint to be added to an Express application.

How to use

It's simple. Just import it and use it:

   const DojotLogger = require("@dojot/dojot-module-logger-nodejs");
   DojotLogger.logger.debug("This is an example", {filename: "my_module"});

You can change its current log level by calling:

   DojotLogger.logger.setLevel("info");

You should definitely check out winston documentation for more information about how to use it.

You can add an endpoint to your component as well:

   var bodyParser = require("body-parser");
   var express = require("express");
   var app = express();

   app.use(bodyParser.json());
   app.use(DojotLogger.getHTTPRouter());
   app.listen(10001, () => {
       DojotLogger.logger.info(`Listening on port 10001.`);
   });

Thus you can call:

   curl -X PUT http://localhost:10001/log -H "Content-Type:application/json" -d '{"level" : "debug"}'

to change current log level. Currently supported levels are:

  • debug
  • info
  • warn
  • error

In order to get current log level, just send a GET request to the same endpoint:

   curl -X GET http://localhost:10001/log 

dojot-module-logger-nodejs's People

Contributors

giovannicuriel avatar raulnegreiros avatar rascaraficci 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.