Skip to content

feat(browser): add logEventToObject helper for transmit.send#2387

Open
mcollina wants to merge 1 commit intomainfrom
feat/log-event-to-object
Open

feat(browser): add logEventToObject helper for transmit.send#2387
mcollina wants to merge 1 commit intomainfrom
feat/log-event-to-object

Conversation

@mcollina
Copy link
Member

@mcollina mcollina commented Feb 3, 2026

Summary

  • Add logEventToObject helper function that converts a LogEvent to a log object similar to what Node.js transports receive
  • This makes it easier to send formatted logs to upstream logging systems (like DataDog) from transmit.send
  • The function merges child bindings into a single object, extracts the merging object from the first message, and formats the message string with arguments

Usage

const pino = require('pino')
const { logEventToObject } = require('pino')

const logger = pino({
  browser: {
    transmit: {
      send(level, logEvent) {
        const logObject = logEventToObject(logEvent, { messageKey: 'msg' })
        // Send logObject to your logging service
        // { time, level, ...bindings, msg }
      }
    }
  }
})

Test plan

  • Added unit tests for logEventToObject function
  • Tests cover basic conversion, binding merging, message formatting, custom messageKey, and integration with transmit.send
  • Verified TypeScript definitions compile correctly
  • All browser-transmit tests pass

Closes #1556

Add a helper function that converts a LogEvent to a log object
similar to what Node.js transports receive. This makes it easier
to send formatted logs to upstream logging systems from the browser.

The function merges child bindings, extracts the merging object,
and formats the message string with arguments.

Closes #1556
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pino in the browser prints the log bindings weirdly

1 participant