Show HN: I've made an easy to extend and flexible JavaScript logger
17 points| inshinrei | 7 months ago |github.com | reply
Would like to hear a feedback from you!
17 points| inshinrei | 7 months ago |github.com | reply
Would like to hear a feedback from you!
[+] [-] Thomaschaaf|7 months ago|reply
[1]: https://github.com/pinojs/pino
[+] [-] matsemann|7 months ago|reply
[+] [-] inshinrei|7 months ago|reply
As of performance, let's address why "pino" is faster than console.log. Pino avoids using the console directly, as it is designed for the node environment and appears to utilize stdout.write for output. This approach gives Pino a performance advantage in benchmarks. As of now, "halua" is yet to be optimized. Your comment prompted me to conduct a quick benchmark tho. If you're interested, here are the results for 10_000 iterations:
// halua (console): 358ms (NewTextHandler(console.info))
// pino: 233ms
// halua (stdout): 253ms (NewTextHandler((data) => process.stdout.write(data)))
There's also JSON handler in halua, which is 10%-20% slower than text handler
[+] [-] unknown|7 months ago|reply
[deleted]
[+] [-] gus_massa|7 months ago|reply
[+] [-] inshinrei|7 months ago|reply
[+] [-] cluckindan|7 months ago|reply
https://www.npmjs.com/package/debug
[+] [-] inshinrei|7 months ago|reply
[+] [-] lnxg33k1|7 months ago|reply
[+] [-] inshinrei|7 months ago|reply
import {Level, halua, NewTextHandler, NewJSONHandler, NewWebConsoleHandler} from 'halua'
// an array of handlers that would accept logs
let handlers = [
]if (debug) {
}// now we have to apply the handlers we created
let logger = halua.New(handlers)
// or
halua.setHandler(handlers)
// later, you may call .New on any logger instance to get a new instance