lrlna / pino-colada Goto Github PK
View Code? Open in Web Editor NEWcute ndjson formatter for pino ๐ฒ๐น
License: MIT License
cute ndjson formatter for pino ๐ฒ๐น
License: MIT License
pretty-print
& prettifier
the new recommended way of integrating a prettifier via API is using a pino.transport
. pino-pretty
supports this so can probably checked to see an example of how.
Maybe it's a good idea to remove pad-left
and pad-right
and replace it with build in String.prototype.padStart
and String.prototype.padEnd
.
https://www.npmjs.com/package/left-pad
When using pino-colada
programmatically as per the docs:
const pino = require('pino')
const logger = pino({
prettifier: require('pino-colada')
})
logger.info('hi')
Nothing happens. When I add prettyPrint
to the options it starts working:
const pino = require('pino')
const logger = pino({
prettyPrint: {},
prettifier: require('pino-colada')
})
logger.info('hi')
... but only for the first log line. All others after that are the default "raw" JSON
If you log with log.fatal(err, 'something went wrong')
you only see `something went wrong' in your log. It would be better if you got your stacktrace so you can see where the error occurred. (It does seem to log objects given post the error message, just not pre)
Hi,
in fastify-cli we have a report of this error with the v1.6.0 release:
To reproduce:
npx fastify-cli generate pretty
cd pretty/
npm i
// edit the package.json adding "-P" flag in the start script
npm start
// now we have the error
// to solve:
npm ls pino-colada
// you should see 1.6.0
// installing previous version works:
npm i [email protected]
npm start
// all works fine
There are some fixes we should apply to our code base?
We use pino-colada here:
https://github.com/fastify/fastify-cli/blob/b6e7caba7e8f2644f5243f9d94902faacfbda886/start.js#L98-L102
Thanks
The stack trace:
stream.on('close', function () {
^
TypeError: stream.on is not a function
at destroyer (C:\Users\behem\workspaceFastify\asd\boooom\node_modules\pump\index.js:26:10)
at C:\Users\behem\workspaceFastify\asd\boooom\node_modules\pump\index.js:70:12
at Array.map (<anonymous>)
at pump (C:\Users\behem\workspaceFastify\asd\boooom\node_modules\pump\index.js:67:26)
at runFastify (C:\Users\behem\workspaceFastify\asd\boooom\node_modules\fastify-cli\start.js:101:5)
at start (C:\Users\behem\workspaceFastify\asd\boooom\node_modules\fastify-cli\start.js:50:10)
Original issue ref: fastify/fastify-cli#235
Hello,
I tried to update from 2.1.0 to 2.2.0 and pino-colada fails with the error env: node\r: No such file or directory
.
Small googling revealed it's connected with line endings: https://stackoverflow.com/questions/30344858/node-script-executable-not-working-on-mac-env-node-r-no-such-file-or-directo
Thank you
OS: macOs Big Sur 11.2.3
node: 14.17.6
Hi,
I got so confused when reading through pino, pino-pretty, pino-colada docs...
I tried this:
const app = fastify({
logger: {
level: 'info',
prettifier: require('pino-colada')
}
})
with no luck.. And I really don't want to do the |
thing.. I just want the app to print the pretty logs. Is that possible?
Heya, first off thank you for this awesome tool and contribution to the pino ecosystem!
This formatter made it easy and fun to remove the conditional pretty-printing logic from our app in favor of pure, pluggable, ndjson output. Excellent idea and much appreciated contribution.
To the crux of this issue: I'd like to propose dropping dim
modifiers from log statements to make the output more accessible. Dim red for error statements is particularly troubling and is the main change I'll champion here.
Totally understand that there are a lot of host environment settings that play into the rendering of these things. The demo screenshot in the README is beautiful and, while I couldn't figure out what terminal theme was used when capturing it, I took the following screenshots to highlight renderings in iTerm2 w/ default dark theme and Hyperterm with the top 2-most downloaded themes (pokemon and solarized-dark)
Using this script to generate the output: https://gist.github.com/knksmith57/7b673fe77429534a93f2c7ea5ff61c20
What do you think?
Thanks again!
server-sink produces a whole bunch of info besides message
. I think it'd be good to output more data, akin to how garnish
operates
{ name: 'http',
message: 'request',
method: 'GET',
remoteAddress: '::1',
url: '/' }
{ name: 'http',
message: 'response',
method: 'GET',
url: '/',
statusCode: 200,
elapsed: 55,
contentLength: 242 }
What would it take to use the 'main' source file (exported function) as the pretty printer when creating a pino instance. I'm avoiding command-line pipes and using environment variables to control pretty printing.
So something like this....which doesn't work.
import pino from 'pino'
import colada from 'pino-colada'
// import serializeError from 'serialize-error'
let pretty = {}
if(process.env.UCI_DEV || process.env.DEBUG) {
pretty = colada
// pretty = pino.pretty()
// pretty.pipe(process.stdout)
}
let LOG = process.env.UCI_LOG || process.env.UCI_DEV || process.env.DEBUG
const logger = pino({
name: 'UCI',
enabled: !!LOG,
safe: true,
serializers: {
req: pino.stdSerializers.req,
res: pino.stdSerializers.res
}
},pretty)
export default logger
Just as it says in the title. They can be distributed as part of the package or contributed to DefinitelyTyped.
neat idea to check whether bundle size is within tcp constraints --https://twitter.com/davidmarkclem/status/843777314496430080
Hey !
First thanks for pino-colada, it's really great !
However, I have a small usage issue with it, because while pino-colada removing most of the verbose stuff especially regarding requests is awesome, it would be great to have at least small objects with few properties outputed, at least in a verbose
like mode (maybe with a threshold on the number of non object subprops )
@lrlna Are you open to such a feature ? Would you want to implement it, or would you prefer a PR ?
Change prettifier
to customPrettifiers
in the readme
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.