wrapp / wrapp-log.js Goto Github PK
View Code? Open in Web Editor NEWA logging library for Wrapp that outputs logs in accordance with WEP-007
License: MIT License
A logging library for Wrapp that outputs logs in accordance with WEP-007
License: MIT License
To make the log output easier to read, the attribute order should be in predefined order (with mandatory attributes serialized first).
Today the following log output generates the following string:
logger.info(randomText(), { data: randomText(), extra: randomText() })
logger.info(randomText(), { data: randomText(), extra: randomText() })
logger.info(randomText(), { data: randomText(), extra: randomText() })
> {"data":"ucu3ti","extra":"s3lpiboiv7q7z","level":"info","msg":"jgw nec936a8wq","timestamp":"2017-08-31T18:01:36.642Z"}
> {"data":" gez","extra":"lqbmek7xl1 t k","level":"info","msg":"52mgeynl4dcgmju9","timestamp":"2017-08-31T18:01:36.643Z"}
> {"data":"sqr or6o","extra":"kggl o70 uvae","level":"info","msg":" 38ls oflx8gi9ebd","timestamp":"2017-08-31T18:01:36.643Z"}
It would be easier to read by reformatting the output like:
> {"level":"info","msg":"jgw nec936a8wq","data":"ucu3ti","extra":"s3lpiboiv7q7z","timestamp":"2017-08-31T18:01:36.642Z"}
> {"level":"info","msg":"52mgeynl4dcgmju9","data":" gez","extra":"lqbmek7xl1 t k","timestamp":"2017-08-31T18:01:36.643Z"}
> {"level":"info","msg":" 38ls oflx8gi9ebd","data":"sqr or6o","extra":"kggl o70 uvae","timestamp":"2017-08-31T18:01:36.643Z"}
or
> {"level":"info","timestamp":"2017-08-31T18:01:36.642Z","msg":"jgw nec936a8wq","data":"ucu3ti","extra":"s3lpiboiv7q7z"}
> {"level":"info","timestamp":"2017-08-31T18:01:36.643Z","msg":"52mgeynl4dcgmju9","data":" gez","extra":"lqbmek7xl1 t k"}
> {"level":"info","timestamp":"2017-08-31T18:01:36.643Z","msg":" 38ls oflx8gi9ebd","data":"sqr or6o","extra":"kggl o70 uvae"}
When an extra attribute in a log statement contains a circular reference, the standard JSON.stringify crashes.
When a logger object is passed down from a server, the request ID should always be included. When passing down the logger, that attribute will be added to the logger object and serialized together with all added attributes at log write time.
var logger = require('wrapp-log')
logger.info('Hello', { data: 123 })
> {"data":123,"level":"info","msg":"Hello","timestamp":"2017-08-31T17:13:47.376Z"}
var logger = require('wrapp-log')
var preBakedLogger = logger.withAttributes({ data: 123 })
preBakedLogger.info('Hello', { more: 'axa' })
> {"data":123,"more":"axa","level":"info","msg":"Hello","timestamp":"2017-08-31T17:17:01.813Z"}
logger.info('Hello', { more: 'axa' })
> {"more":"axa","level":"info","msg":"Hello","timestamp":"2017-08-31T17:17:01.813Z"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.