Giter Club home page Giter Club logo

escriba's People

Contributors

belchior avatar dalthon avatar davidpvilaca avatar deivis avatar edrzmr avatar evaporei avatar guilhermearrudda avatar hails avatar itsdaiego avatar lucianopf avatar marcoworms avatar matheusvellone avatar mccraveiro avatar murilohns avatar piiih avatar vitorabner avatar zignd 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

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  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

escriba's Issues

Not json output is expected?

@vitorabner Running the docker example there are one output without json wrap, this is expected?

{"id":"cj5mkq9di001l0glb65sh6e68","method":"DELETE","url":"/escriba","body":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot DELETE /escriba</pre>\n</body>\n</html>\n","httpVersion":"1.1","user-agent":"axios/0.16.2","statusCode":404,"level":"warn","from":"response","service":"Escriba App","startTime":1501168102904,"hostname":"725514a5094d","pid":16,"latency":1}

(node:16) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 30): Error: Request failed with status code 404
(node:16) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 32): Error: Request failed with status code 404
{"id":"cj5mkqbom001m0glb8o8ae6q1","message":"Info log","level":"info","service":"Escriba App","startTime":1501168105894,"hostname":"725514a5094d","pid":16}

{"id":"cj5mkqbom001n0glb4buqni43","message":"Warn log","level":"warn","service":"Escriba App","startTime":1501168105894,"hostname":"725514a5094d","pid":16}

{"id":"cj5mkqbom001o0glb163prdu5","message":"Error log","level":"error","service":"Escriba App","startTime":1501168105894,"hostname":"725514a5094d","pid":16}

Should log req.id by default?

In my opinion, req.id is a powerful tool that helps to trace a request between services, so why not log this by default?

Make escriba filebeat friendly

  • support to log clean json object, without color or timestamp
  • always output in json format
  • support to configure a list of enviroment variable to be added on log objects

Declaration files .d.ts

hello everyone ๐Ÿค˜

i'm using escriba in my projects and i always ask about the types. Many npm libs have a types (by community @types or itself generate .d.ts).

Most of my Node projects is written in TypeScript and @types doesn't seem like a good option.. My proposal is to refactor to TypeScript language and then for each published version a type declaration will be automatically generated.

Fork and branch: https://github.com/davidpvilaca/escriba/tree/refactor/typescript

I didn't have time to write types correctly but I hurried to present the idea to get a feedback.

"route.path" doesn't match using nested routes

I'm having some problems using the route.path parameter on propsToLog using nested routes with Express Router. Searching the internet I saw that this is an issue of the Express package itself.

See: expressjs/express#2879

Using express router with nested routes, for example:

// routes/users.js
const usersRouter = Router({ mergeParams: true });

usersRouter.get('/:id', (request, response) => {
  console.log(request.route.path) // "/:id" (instead of "/users/:id")
  return response.status(200).json([/* list of users */])
})

// app.js
const app = express();

app.use('/users', usersRoutes)

I would like to have a property on log that has the value /users/:id but, using route.path, I always get the value :id which can be mixed with any other route that has a /:id route, since they will log the same value. This ends up making it very difficult to filter the logs by route.

My suggestion: Can we create an own property of Escriba to handle this?

Using route.params we can create a value that uses the request.originalUrl and can create the same value as route.path does but full with parent paths/suffixes.

Example code (suggestion by @asheba):

const reverseMapParamValuesToKeys = params => {
  const entries = Object.entries(params);
  return entries.reduce(
    (map, [key, value]) => ({ ...map, [value]: `:${key}` }),
    {},
  );
};

const paramValuesToKeys = reverseMapParamValuesToKeys(request.params);
const originalUrl = request.originalUrl || '';
const splittedUrl = originalUrl.split('/');
const replaceWithParams = splittedUrl.map(
  urlPart => paramValuesToKeys[urlPart] || urlPart,
);
const path = replaceWithParams.join('/');
const pathWithoutQueryString = path.split('?')[0];
const routePath = pathWithoutQueryString;

console.log(routePath) // /users/:id

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.