Better HN
topnewbestaskshowjobs
Log inSign up

inshinrei

10 karma · joined Aug 18, 2025 (1y ago) · 11 submissions

Submissions

comment 1y ago · link · parent

will do

comment 1y ago · link · parent

thank you!

comment 1y ago · link · parent

The primary purpose of the "halua" logger is to provide easy control over log levels and output systems in a single place

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

comment 1y ago · link · parent

i'm also leaving an example of production app setup here:

import {Level, halua, NewTextHandler, NewJSONHandler, NewWebConsoleHandler} from 'halua'

// an array of handlers that would accept logs

let handlers = [

  NewJSONHandler(writeToZipArchive, {level: Level.Info}), // writes to client-size archive, only logs that are Info-Level or higher

  NewTextHandler(sendToServer, {level: Level.Notice}), // writes to server, only logs tat are Notice-level or higher
  
  NewTextHandler(sendUserAction, {level: Level.Info + 1}), // we will log user actions on a different level, so that it will be easy to filter

  NewTextHandler(sendToErrorMonitoringSystem, {level: Level.Fatal}) // writes to monitoring system
]

if (debug) {

  handlers.push(NewWebConsoleHandler(self.console)) // writes to web / nodejs console
}

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

comment 1y ago · link · parent

thanks for highlighting, I've updated the README file and move docs on top with "documentation" header so that it will be easier to find

6.

Show HN: I've made an easy to extend and flexible JavaScript logger(github.com ↗)

17 points · by inshinrei · 1y ago · 9 comments

7.

Ask HN: Why my post under "show HN" may not be public available?

1 points · by inshinrei · 1y ago · 2 comments