gymnast includes a simple logger that can be customized to match your needs.

By default it uses console and reports all warnings and errors. The production build only includes the error code (you can find descriptions here). The development one also includes a short description and link to its respective wiki page.

To change the logging level you can call log.setLevel like this:

import { log } from 'gymnast'

log.setLevel('error')

To customize the logger itself, you can call:

import { log } from 'gymnast'

const newLogger = {
  info: () => null,
  warn: () => null,
  error: async (...err) => 
    await fetch('/report', {
      method: "post",
      body: JSON.stringify(err)
    })
}

log.setLogger(newLogger)

This allows you to track and report client side layout errors. If you prefer to throw when errors occur, you could do something like:

import { log } from 'gymnast'

const newLogger = {
  info: console.info.bind(console),
  warn: console.warn.bind(console),
  error: (...err) => {
    throw new Error(err.join(', '))
  }
}

log.setLogger(newLogger)