Code Monkey home page Code Monkey logo

woodlot's People

Contributors

aniladpushup avatar arunadpushup avatar arunmichaeldsouza avatar dhirajadpushup avatar msamblanet avatar sirius226 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

woodlot's Issues

Log to console without a file

If I attempt to configure woodlot to log to console and provide no streams, it logs the following message and does not finish initializing:

woodlot[warning]: Please provide at least one valid file stream to start logging. More info here - https://github.com/adpushup/woodlot

Based on a scan of the code this seems intentional but I have use cases where I do not need to log to a file (the stdout is collected and maintained) and in some cases (namely during dev) would like to preserve the console formatting...

I can workaround with a noop stream but based on scanning the code, it still formats the log to write to a file and then does nothing with it...

Would you be open to a PR to allow no streams to be specified if the console output is enabled?

body{} is showing empty when i send text type data from postman

Hi Team,

Below is the code how i initialize woodlot in my application.
consider i imported all required libs..

//logger
app.use(woodlot({ streams: ['./log/quotes.log'], stdout: false, routes: { whitelist: ['/','/rest/v1/quotes'], strictChecking: false }, userAnalytics: { platform: true, country: true }, format: { type: 'json', options: { cookies: true, headers: true, spacing: 4, separator: ',' } } }));

and when i hit the endpoint with some text in request body, i am not getting anything in body{ } part.
(POST req to my endpoint, no headers, no auth, in Body, it's just a text type)

er1

the response logged is:
{ "responseTime": "6ms", "method": "POST", "url": "/rest/v1/quotes", "ip": "::1", "body": {}, "params": {}, "query": {}, "httpVersion": "1.1", "statusCode": 200, "timeStamp": "15/Jul/2020:14:27:07 +0000", "contentType": "application/json; charset=utf-8", "contentLength": "56", "userAgent": "PostmanRuntime/7.26.1", "referrer": null, "userAnalytics": {}, "headers": { "content-type": "text/plain", "user-agent": "PostmanRuntime/7.26.1", "accept": "*/*", "postman-token": "94b2a128-84e3-496f-9b2b-f556960ffce7", "host": "localhost:3000", "accept-encoding": "gzip, deflate, br", "connection": "keep-alive", "content-length": "3" }, "cookies": {} },

and you can find body is empty..

but when i change body type to JSON, i am getting the data in body{ } part.
even i tried to change the 'type' field in 'format' section like:
type: 'text', or
type: 'text/html'
i am able to get the logs but body{ } is missing.

am i doing anything wrong ? How can i fix this ?

Logging json format as one-line compact string

Hi, is there a way for json format logger to log as one-line compact string?

It seems in utils.js all falsy values for spacing will be replaced by default value:
spacing = spacing || constants.DEFAULT_JSON_SPACING;

Could we support spacing = 0 as compact string flag or add another option compact: true/false?

Access the log file with js

How can i access the log file within js?
Imagine i want to use the logger as json database. And if app crashes i need the last entry to pick up where it crashed...

Either enclose the all thing in an array, or separate the log entries with a comma?

Thanks, and awesome work BTW.

Can you add custom log values?

Is there a way to pass additional properties to the logger? For instance:

logger = require('woodlot').middlewareLogger

app.use(function(req) {
  return logger.set('userId', req.user.id); // <-- add user id to the logger
});

app.use(logger({
  streams: './logs/mylogs.log',
  stdout: false,
  userAnalytics: {
    platform: true,
    userId: true, // <-- display the user id in logs
    country: false
  },
  format: {
    type: 'json',
    options: {
      cookies: true,
      headers: true,
      spacing: 4,
      separator: '\n'
    }
  }
}));

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.